Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


how can i declare Classes  in c++

Posted on 2000-04-22
Medium Priority
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.
Question by:fathikhid
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

Expert Comment

ID: 2740111
sorry, we are not allowed to do school project.

Expert Comment

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{
//here goes the private data members
//and the private methods mostlly data
//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{
int x;
myclass(int 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


Accepted Solution

rkcth earned 300 total points
ID: 2740752
class myclass
void myclass();
void ~myclass();

//code for constructor goes here

//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.

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
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 viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

705 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