what is instantiated

i am trying to push_back a vector but the compailer tell me:
instantiated from here

non-static const member `const std::string Robot::name', can't use default assignment operator

what it means?
closed account (zb0S216C)
It basically means that at some point in your program, you've used the assignment operator on "Robot::name" in attempt to modify its value. But because "Robot::name" is constant, it cannot be modified, so the compiler told you where you attempted to modify "Robot::name" so that you could fix it.

"Instantiated from here" basically means: "at this point in your program."

Wazzak
Last edited on
so i can't push_back a vector that one of is object is const??
"Instantiation" is creating an object. An object is an "instance" of a class, so creating an object is "instantiation".

As to why you're getting that particular error, we'd need to see the code to be sure. But the error message should tell you the line number in which the problem is occurring, so you should be able to see it yourself.
closed account (zb0S216C)
student123 wrote:
"so i can't push_back a vector that one of is object is const??"

No. One of the requirements of the "std::vector" is that objects must be copyable. In other words, the type of data the "std::vector" holds must have a default constructor, a publicly accessible copy-constructor and must be non-constant.

@MikeyBoy: "Instantiation" means different things in different contexts. Yes, "instantiation" means to create an object of a class, but it also means what I said above. "Instantiated from here" is used to extend an error, for example:

1
2
3
4
5
6
7
8
9
void Function( )
{
  // ...
}

int main( )
{
   Function( 10 ):
}

Will produce:
"Error: no matching function call to ::Function( int ) instantiated from here...".

Wazzak
Last edited on
"Error: no matching function call to ::Function( int ) instantiated from here...".


What compiler produces that inaccurate error message?
closed account (zb0S216C)
@cire: GCC.

Wazzak
Hmph.

From gcc, I get:
error C2660: 'Function' : function does not take 1 arguments
Topic archived. No new replies allowed.