pass arguments to constructor from pointer object

hello,
I've been playing around with some examples from a tutorial I'm using to learn c++, and so I made a simple class, dog, that has a constructor looking for 2 arguments.

1
2
3
4
5
6
7
8
9
10
11
 class dog {
	public:
		dog(int age, int weight);
		~dog();
	    void bark() const;
		int getAge() const;
		int getWeight() const;
	private:
		int itsAge;
		int itsWeight;
	};


all the dog constructor does is initialize the two member variables

1
2
3
4
	dog::dog(int age, int weight): itsAge(age), itsWeight(weight) 
	{
		cout << endl << "Constructor Building!" << endl; }


my problem is that I am trying to make a pointer dog on the free store using this:

 
dog * pdog(6,50) = new dog;


but the code won't compile. so how do you pass arguments to a constructor from a pointer object?
You have the parameters in the wrong place:

dog *pdog = new dog(6,50);
thank you very much!
Topic archived. No new replies allowed.