The *this* pointer is not used in this way. It's sole purpose is to return a pointer to an instance's "self". Look at it this way: In C, there were no undeclared instances, since you had to pass a structure as a parameter(otherwise make it global...). So it was easy as pie to assign a pointer to a named object. In C++, we use member functions, which of course, are "attached" to the instance calling them. Hence, how do you return a pointer to an unnamed object??! The *this* pointer was born. Now, if you find yourself trying to access specific members of the class with it, you are off-track. So in other words, you can completely omit it in your case.
Here's an example of using it properly(albeit nonsensically...), then a simple rewrite of your code...
Code:
vehicle *ReturnIfInitialized() {
if(name != NULL) return this;
return NULL;
}
//............
int main()
{
vehicle car(NULL);
vehicle *ptr = car.ReturnIfInitialized() ;
if( ptr == NULL)
cout << "gimme a name!!" << endl;
else
cout << "Thanks for naming me" << ptr->name << "!!" << endl;
getch();
return 0;
}
//............
Code:
vehicle::vehicle(char n[10]){ // defenition of constructor
name=n;
cout <<"new vehicle was created its name is "<<endl;
cout << name;
return;
};