how can i declare Classes  in c++

Posted on 2000-04-22
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 100 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

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!

Question has a verified solution.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

627 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