How do you use a pointer to a class object??

I am in my second term of pogramming (nubie).  I am writing a code for a class assignment.  I am supposed to create a class and ask the user to enter stuff in the constructor. Then I am supposed to create a Print function that outputs that stuff.  In main I am supposed to create a group object and a pointer this group object.  My program is supposed to print using both the object name and the pointer name.

My problem is the pointer.....I'm not sure how to do this.   I will post what I have and ask for your guidance again.
// Day7.cpp : Defines the entry point for the console application.
//
 
#include <iostream>
 
using namespace std;
//declaration section
 
class Group
{
public:
	Group();
	void Print();
 
private:
	int NumberInGroup;
	char Name[75];
};
//implementation section
Group::Group()
{
	cout << "Enter the number in the group: ";
	cin >> NumberInGroup;
	cout << "Enter the name of the group: ";
	cin.getline(Name,74, '\n');
}
void Group::Print()
{
	cout << "The group called \"" << Name << "\" has " << NumberInGroup << "members.\n";
}
int main()
{
	Group obj;
	Group *ptr = 0;
 
	obj.Print();
 
	*ptr = obj;
 
	Group *ptr.Print();
 
	
	return 0;
}

Open in new window

b_acsAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

b_acsAuthor Commented:
Ok I think it should be more like this, but still not right......
// Day7.cpp : Defines the entry point for the console application.
//
 
#include <iostream>
 
using namespace std;
//declaration section
 
class Group
{
public:
	Group();
	void Print();
 
private:
	int NumberInGroup;
	char Name[75];
};
//implementation section
Group::Group()
{
	cout << "Enter the number in the group: ";
	cin >> NumberInGroup;
	cout << "Enter the name of the group: ";
	cin >> Name;
}
void Group::Print()
{
	if(NumberInGroup != 1)
	cout << "The group called \"" << Name << "\" has " << NumberInGroup << " members.\n";
	else
		cout << "The group called \"" << Name << "\" has " << NumberInGroup << " member.\n";
}
int main()
{
	Group obj;
	Group *ptr = 0;
 
	obj.Print();
 
	*ptr = obj;
 
	ptr->Print();
 
	
	return 0;
}

Open in new window

0
b_acsAuthor Commented:
I got it!!!
int main()
{
	Group obj;
	Group *ptr;
 
	obj.Print();
 
	ptr = &obj;
 
	ptr->Print();
 	
	return 0;
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Infinity08Commented:
>> I got it!!!

Correct :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.