Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple question about array of classes 1

Status
Not open for further replies.

intrepidX

Vendor
Jan 11, 2002
1
CA
i want to create an array of a certain amount of classes, which will be decided by the user. How do i go about this? simply typing
cin>>nCnt
CClass test[nCnt]
was not succesful. Thanks in advance for your help
 
You'll need to dynamically allocate and destroy the classes (using new and delete) after the user inputs the number.
[ignore]
CClass* pTest = (CClass*) new CClass[nCnt];
...
delete [] pTest;
[/ignore]
Use the arrow -> operator rather than the dot . operator to access the class members and functions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top