954,496 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Objects vs Types: Strings, char, int.

3.3 - Objects vs Types: Strings, char, int.
Strings used to be an array of char in C-style coding. Now they're objects in C++.
Does this mean that int and char are not objects?

crapgarden
Junior Poster in Training
58 posts since Jul 2010
Reputation Points: 16
Solved Threads: 0
 

>>Does this mean that int and char are not objects?
Yes -- they are not objects. They are data types. A string is not an object either. It is a c++ class that is defined in header file. Objects are an intstance of a data type or c++ class

int x; // x is an object
std::string name; // name is the object
char address[255]; // address is an object
Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

>>Strings used to be an array of char in C-style coding. Now they're objects in C++.
Forget about what it used to be is C. std::string is a class. An instance of a class
is called an object, so std::string name , here name is an object, because
it is an instance of a class.

>>Does this mean that int and char are not objects?
As pointed out, int and char are primitive data types. The are P.O.D

firstPerson
Senior Poster
3,923 posts since Dec 2008
Reputation Points: 841
Solved Threads: 608
 

Awesome, Thank you both!

crapgarden
Junior Poster in Training
58 posts since Jul 2010
Reputation Points: 16
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: