Omgili - forum search, search forums  
  

Discussions about const

Displaying 1 - 10 out of 36,969 discussions.  
RSS Feed Options
Time Frame: (Any time)   Minimum number of replies: (2)   Minimum number of discussing users: (0)
  |  

Page: 1   2   3   4   5   6   7   8   9   10  
Keep this page open to be updated with the newest discussions automatically.
Labelled as homework because this was a question on a midterm I wrote that I don't understand the answer to. I was asked to explain the purpose of each const in the following statement: const char const * const GetName() const { return m_name; }; So, ...
Started by on , 8 posts by 8 people.  
It helps to read things like this from....
Also, the last const must come before the function body.
Remove the "const" after "char" and before the "*".
You have one more const than is syntactically allowed, that code would not compile.
Hi, as its legal to convert a pointer to non-const to a pointer to a const.. similarly,why isnt it legal to convert (pointer to pointer to non-const) to a (pointer to pointer to a const) i.e, char *s1 = 0; const char *s2 = s1; // OK... char *a[MAX]; /...
Started by on , 4 posts by 4 people.  
From the standard: const char c = 'c'; char* pc; const char** pcc = &pc; // not allowed *pcc = &c; *pc = 'C'; // would allow to modify a const object Ignoring your code and answering the principle which expects a const char....
Assume I do this operation: (X / const) * const with double-precision arguments as defined by IEEE 754-2008 , division first, then multiplication. const is in the range 0 < ABS(const) < 1 . Assuming that the operation succeeds (no overflows occur...
Started by on , 4 posts by 4 people.  
If you read those theorems, it looks like taking const = 1/n where n is the sum = 1000.0010101011010001010101111000111101110100001 1 (BTW, the "* const" part of the expression is unnecessary: the....
But there is no explicit proof of that).
Ask your Facebook Friends
Hi, I need to call a const function from a non-const object. See example struct IProcess { virtual bool doSomeWork() const = 0L; }; class Foo : public IProcess { virtual bool doSomeWork() const { ... } }; class Bar { public: const IProcess& getProcess...
Started by on , 11 posts by 11 people.  
If the methods are overridden....
It's calling a non-const method from a const object that is forbidden.
Calling a const method of a non-const object is fine.
You don't have to do any casting trickery if the function is not overloaded .
I have code like this: NSData *data = [NSData dataWithContentsOfURL:objURL]; const void *buffer = [data bytes]; [self _loadData:buffer]; [data release]; the "_loadData" function takes an argument like: - (void)_loadData:(const char *)data; How do I convert...
Started by on , 3 posts by 3 people.  
You mustn't release _loadData:(const char *) buffer];.
Just like you would in C: [self _loadData:(const char *)buffer]; should work.
As an extension to this question Are const_iterators faster? , I have another question on const_iterators . How to remove constness of a const_iterator ? Though iterators are generalised form of pointers but still const_iterator and iterator s are two...
Started by on , 11 posts by 11 people.  
I don't think(3); vector<int>::const....
You can subtract the begin() iterator from the const_iterator to obtain the position the const_iterator is pointing to and then add begin() back to that to obtain a non-const iterator.
Using V1.8 z/OS XL C compiler, with warnings jacked-up using INFO(ALL), I get the following warning on line 4 of the code below: WARNING CCN3196 Initialization between types "const int** const" and "int**" is not allowed. 1 int foo = 0; 2 int *ptr = &...
Started by on , 4 posts by 4 people.  
Consider this code (I shuffled const around a bit to make it clear const** pp = &p; // presumably ok int const c = 123; *pp = &c; // okay, &c is int const*, and *p is int const* lvalue *....
It's a type safety violation.
While striving for const-correctness, I often find myself writing code such as this class Bar; class Foo { public: const Bar* bar() const { /* code that gets a Bar somewhere */ } Bar* bar() { return const_cast< Bar* >( static_cast< const Foo*...
Started by on , 13 posts by 13 people.  
Use following trick: ....
You can do something like this: class Bar; class Foo { public: const Bar* bar() const { return getBar(); } Bar* bar() { return getBar(); } private: Bar* getBar() const {/* Actual code */ return NULL mutable.
Let's say you have a class class C { int * i; public: C(int * v):i(v) {}; void method() const; //this method does not change i void method(); //this method changes i } Now you may want to define const instance of this class const int * k = whatever; const...
Started by on , 8 posts by 8 people.  
When you are passing by value (as in your....
Verboseness sometimes, but const correctness is a common standard behaviour that you can't just redefine, it is completely irrelevant whether the constructor's parameter is declared const or not.
I have two getter members: Node* prev() { return prev_; } int value() { return value_ } Please note the lack of const identifiers (I forgot them, but now I want to know why this won't work). I am trying to get this to compile: Node(Node const& other) ...
Started by on , 6 posts by 6 people.  
This type of operation is strictly forbidden by const....
You're attempting to call two methods which are not const an a const reference (calls to prev and value).
You're not trying to do a non-const to const conversion.
Page: 1   2   3   4   5   6   7   8   9   10  
Related Searches
const    vba array multiply all by const    thunderbird redeclaration const MSG_FLAG_READ    cannot convert parameter 2 from 'const unsigned short ' to 'unsigned short '   
More Information


Forum Search About Omgili Help Plugins Forum/Board Owners Privacy

i
In Title
In Topic
In Reply
Exclude
Boost