Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 186
  • Last Modified:

How to Create a New Class?

Hi,

I am using VC++ 6.0 May I know how to create a new class from a existing workspace? I want to put my functions in the new class such that my main program can call the functions from it. In this way my main program will look neater. Can the values be passed from the new class to the main program and vice versa?

I know this is a basic qns and may have been asked several times. Appreciate if someone willingly to teach me again...preferably step by step explanations. Thank You!
0
Vokey
Asked:
Vokey
1 Solution
 
SalteCommented:
Isn't there a separate menu entry under 'file' 'new' or whatever it is called?

I think you can also use the project viewer and right click on the project icon there and you get a pop up menu where one of the selections is 'new class...'.

Alf
0
 
SalteCommented:
Another thing is also to just make the new class,

define a new .h file in the project and declare a new class there, when you save the class viewer should update itself and include the new class.

Alf
0
 
imadjinnCommented:
In the menu go to 'Insert|New Class...'

Make it a generic class.

Add functions.

Repeat as desired.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
VokeyAuthor Commented:
Thanks Salte and imadjin for the answer..I had tried those before.

For example, I create a generic class called Generic.cpp and add a function called Generate().

I tried to call for Generate() in my main program which is in another .cpp, the complier doesnot recognise Generate() function. How do I make it recogize it?
0
 
rveluthattilCommented:
The reason why it is not able to could be because either the new class files (Generic.cpp and Generic.h) are not added to the workspace. By default they are generally but there is a possiblity. Also did you create an object of the class Generic in your main application unless an object is created you wont be able to invoke the functions within that class.
0
 
VokeyAuthor Commented:
Hmmm...well you are correct, by default these two files(Generic.cpp and Generic.h) are in the workspace and I had also included (#include "Generic.h") at the start of my main program.

Can you explain again about creating an object of class Generic in my main application? How do I go about creating it?

Thank you!

0
 
VokeyAuthor Commented:
Hmmm...well you are correct, by default these two files(Generic.cpp and Generic.h) are in the workspace and I had also included (#include "Generic.h") at the start of my main program.

Can you explain again about creating an object of class Generic in my main application? How do I go about creating it?

Thank you!

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now