?
Solved

How to Create a New Class?

Posted on 2003-02-19
7
Medium Priority
?
185 Views
Last Modified: 2010-04-01
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
Comment
Question by:Vokey
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 12

Expert Comment

by:Salte
ID: 7983101
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
 
LVL 12

Expert Comment

by:Salte
ID: 7983105
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
 
LVL 1

Expert Comment

by:imadjinn
ID: 7984828
In the menu go to 'Insert|New Class...'

Make it a generic class.

Add functions.

Repeat as desired.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:Vokey
ID: 7984978
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
 

Accepted Solution

by:
rveluthattil earned 100 total points
ID: 7985098
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
 

Author Comment

by:Vokey
ID: 7986289
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
 

Author Comment

by:Vokey
ID: 7986290
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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question