need help on Understanding objects and classes

So i need help understanding classes and objects. I know how to declare objects but not sure if im right or not. Here is an example i made up. What i want to know is if order x(4,'C') and order x; in the main function are definitions of an object. It looks like it is but it also looks like its calling to the constructors in the class. Hope you guys can clear any confusion that i have. Thanks a bunch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include<iostream>

using namespace std;

class order
{
public:
	order() {}
	order(int number, char letter) :totalNumber(number) , LETTERS(letter) {}
	
private:
	int totalNumber;
	char LETTERS;

};

int main()
{
	order x(4, 'C');
	order x;
}
Last edited on
'order' is a class. 'x' is an object. It's an instance of the 'order' class.

This second declaration of x should result in a compile fail.

Separately, both of those declarations would be valid. The first would call into your order(int, char) constructor, the second the default constructor.
thank you so much!
Topic archived. No new replies allowed.