Computer programming C++

1 2
   Share on Facebook  
bvpraveen  #104992  Thu, 02 Jun 05 03:54 PM
Dear Praveen,

Pure virtual functions are used to create Abstract classes - class in which objects can't be created and act as only a 'prototype', which is used as a base class.

Another main use of PVF is to 'force' the derived class to define its own function definition. The pure virtual function can have statements too!, in which case the derived class can call the base class' function with the use of scope resolution (::).

Eg: The base class Shape contains all the 'basic function' with some common code. The derived classes - rectange - can overload to define its own funtion.

class shape
{
virtual void print(void) =0 // =0 means it is a pure virtual function
{
cout }
};

class rectange : public shape
{

float length,breadth;

rectangle()
{
length=10;
breadth=20;
}

void print(void)
{
shape::print();
cout cout }
};

void main(void)
{
shape s; // Error
rectange r; // Fine!

r.print();
}

OUTPUT:

Base class
Derived class
10 20
  
Top 150 Contributor
Joined on Sat, Mar 5 2005
Coimbatore, India
Regular Member (507)
hemantchavan  #122594  Sat, 30 Jul 05 10:24 AM

This link could be of some help - there are many other links to C++ programming

www.planet-source-code.com

 

  
Not Ranked
Joined on Thu, Mar 10 2005
New Member (28)
bvpraveen  #128204  Thu, 18 Aug 05 03:01 PM
Google it and you will land in a sea of links.
  
Anonymous  #174512  Mon, 26 Dec 05 08:55 AM

Hello,

      Before start coding firstly you you understood object, method, class and other Which are related with the C++.

 

Thanks:

hytechpro

  
Anonymous  #174514  Mon, 26 Dec 05 08:57 AM

Hello,

     C++ is not different as C.Then before start coding firstly you you understood object, method, class and other Which are related with the Program.

Thanks:

hytechpro

  
rishonly  #177875  Mon, 02 Jan 06 06:55 AM

Hello,

I would suggest to first learn the major OOP concepts,  like  Inheritance, Polimorphism and others.

  
Top 50 Contributor
Joined on Sat, Mar 5 2005
KUMBAKONAM,INDIA
Contributing Member (1,781)
Moderator
Regards, Krish
Ivantalk  #184864  Tue, 17 Jan 06 05:35 PM

Which kind of C++ do you like to learn?

According to my experience, there're 3 kind of C language: Borland C, VC,Turbo C. And I believe it firmly that there's not only one kind of C++. Different developmet environments make the different syntax and standards

  
Not Ranked
Joined on Tue, Jan 17 2006
QuanZhou, Fujian Province, China
New Member (33)
Have your heard of HuaQiao University? I can tell you that it's my university.
1 2
AddThis Feed Button RSS Feed: ESL Information Technology English
© 2008 MediaCET Ltd.
Terms and Conditions & Terms of Service