473,386 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

---what does "virtual int xfunc() = 0;" mean ?

Dear all,

Sorry for i did not paste original propreity codes
See below the fake codes for what I cannot understand.

===============================================
lass A
{
public:
virtual int xfunc() = 0 ;
virtual int yfunc() = 0 ;

};
class C: public A
{
int m_a;
int m_b;
public:
C();
~C();
int xfunc();
int yfunc();
};

the functions' inplementation is as

C::xfunc() {
........
}

================================================== ======
I am using the class C as my programming interface.
I am curious about the function of line "virtual int xfunc() = 0 ;"
I try read my c++ book and cannot got answer to this.
Thank you in advance

Bill Zhao

Jul 22 '05 #1
2 2470

"Bill Zhao" <sz*****@tom.com> wrote in message
news:cf**********@mail.cn99.com...
Dear all,

Sorry for i did not paste original propreity codes
See below the fake codes for what I cannot understand.


Read about pure virtual functions in your textbook.
Jul 22 '05 #2
"Bill Zhao" <sz*****@tom.com> wrote in message
news:cf**********@mail.cn99.com...
Dear all,

Sorry for i did not paste original propreity codes
See below the fake codes for what I cannot understand.

===============================================
lass A
{
public:
virtual int xfunc() = 0 ;
virtual int yfunc() = 0 ;

};
class C: public A
{
int m_a;
int m_b;
public:
C();
~C();
int xfunc();
int yfunc();
};

the functions' inplementation is as

C::xfunc() {
.......
}

================================================== ======
I am using the class C as my programming interface.
I am curious about the function of line "virtual int xfunc() = 0 ;"
I try read my c++ book and cannot got answer to this.


The "=0" means that the member function xfunc is a pure virtual function.
In a nutshell, that means that any class that derives from A must implement
xfunc or else it will be considered abstract (that is, it will be impossible
to create an instance of that class) and the "requirement" for implementing
xfunc is passed on to its subclasses. This feature is often useful when
creating "interface" functions and classes. I'm a little surprised that
your book doesn't cover pure virtual functions.

--
David Hilsee
Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: Steven T. Hatton | last post by:
I just read this in the description of how C++ is supposed to be implemented: "All external object and function references are resolved. Library components are linked to satisfy external...
2
by: Paul T. Rong | last post by:
Sorry I just lost tracks of a series of posts, so I post my question again, hoping someone can help. Here is codes provided by Jeff Smith > Private Sub Form_Load() > Dim db As...
2
by: hsharsha | last post by:
Consider the below code: int main(void) { class inner {}; friend class inner; /* what does this signify???? */ return 0; }
39
by: utab | last post by:
Dear all, Is there a clear distinction how to decide which functions to be members of a class and which not How is your attitude (Your general way from your experiences ...) "If the...
5
by: Niu Xiao | last post by:
I saw a lot of codes like: void foo(void* arg) void bar(void** arg) f((void*)p) but what does void pointer mean in c? I just know it stands for generic pointer. thanks.
3
by: leo.hou | last post by:
Dear experts, I came across the following script in a htm file. Could some one explain why is it passing some parameter to a jpg file? What does it mean? Thanks <script...
7
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
Dim sCoName As String = oDs.Customers(0).CompanyName The part that I want to understand is the oDs.Customers(0). Does oDs.Customers(0) mean 1st row of the datatable Customers. Where can I find...
9
by: PengYu.UT | last post by:
Hi, I'm wondering what 'c' in "cout", "cin" mean? Does it mean "C++"? Or the 'c' in <cassert>? Thanks, Peng
4
by: dolphin | last post by:
Hi All I read a .cpp files,find that static void fun(void){......} int main() { .......... } What does this static function mean?Is it the same as the static
13
by: bobby | last post by:
hello group, what does for( ; ; ) mean in C program Thanks
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.