what is instantiated

May 15, 2013 at 9:39am
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?
May 15, 2013 at 9:52am
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 May 15, 2013 at 9:53am
May 15, 2013 at 10:13am
so i can't push_back a vector that one of is object is const??
May 15, 2013 at 10:14am
"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.
May 15, 2013 at 10:44am
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 May 15, 2013 at 10:45am
May 15, 2013 at 11:10am
"Error: no matching function call to ::Function( int ) instantiated from here...".


What compiler produces that inaccurate error message?
May 15, 2013 at 11:14am
closed account (zb0S216C)
@cire: GCC.

Wazzak
May 15, 2013 at 11:21am
Hmph.

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