Solved

how can i declare Classes  in c++

Posted on 2000-04-22
3
239 Views
Last Modified: 2010-04-02
classes in c++ it introduction to "oop"
then i need program using class.
and what mian of consturcter and destructer?
mianing vertiul;
sen a full programme to explian  this way.
0
Comment
Question by:fathikhid
3 Comments
 
LVL 5

Expert Comment

by:laeuchli
ID: 2740111
sorry, we are not allowed to do school project.
0
 
LVL 1

Expert Comment

by:ntdragon
ID: 2740693
you see we don't do homework but i"ll explain a little that you"ll understand the idea

class structure:

class name_of_the_class{
private:
//here goes the private data members
//and the private methods mostlly data
//members
public:
//here goes the public data members
//and the public methods mostlly methods
//and the c'tors and the d'tors
};

now the idea of the c'tor is to updata the class data members with data at the creation of the class like
class myclass{
private:
int x;
public:
myclass(int x1){
x=x1;
}
then in main
myclass class1(1);
//it will create a class named class1 //type of myclass when the x paramter
//will be 1 <x=1>

//the d'tor used to free memory when
//class is distoried it used to free
//dynamic allocated memroy using the
//funcs delete or delete[]

i hope you got the idea now you"ll have to do the rest by yourself

0
 

Accepted Solution

by:
rkcth earned 100 total points
ID: 2740752
class myclass
{
public:
void myclass();
void ~myclass();
}

myclass::myclass()
{
//code for constructor goes here
}

myclass::~myclass()
{
//code for destructor goes here
}

constuctors are called whenever someone makes a variable of your class type. Destructors are called when it is destroyed.
Hope this helps.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now