Not really.
The class is "as a data type" in the sense that it is a template for creating an object, but it is not an object that you can use.
, . , - .
:
class Person
{
public:
Person() : name("Joe Bloggs") {}
std::string getName() { return name; }
void setName(std::string n) { name = n; }
private:
std::string name;
};
Person. . setName , . :
int main()
{
Person p, q;
p.setName("Jill Bloggs");
q.setName("Bob King");
std::cout << p.getName() << " " << q.getName() << std::endl;
}
, , - , .
, " ", .
- , - . , , :
class foo
{
public:
foo(int value);
void bar();
private:
int x;
};
, , bar, void , x.
x , , . , , bar, :
void foo::bar()
{
}
foo, x , ( ):
foo::foo(int value) : x(value)
{
}