473,326 Members | 2,126 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,326 software developers and data experts.

override function operator question

4
Please help:

class B {
public:
void operator()(){ cout<<"in B()"<<endl;}
};

class D : public B {
public:
void operator()() {
B:: (); // compiler would error: expected unqualified-id before ‘(’ token
cout<<"in D()"<<endl;
}
};

How do I invoke base class function operator from derived class function operator? Thanks
Nov 23 '06 #1
4 4545
Banfa
9,065 Expert Mod 8TB
Replace

Expand|Select|Wrap|Line Numbers
  1.  B:: (); // compiler would error: expected unqualified-id before ‘(’ token
  2.  
with

Expand|Select|Wrap|Line Numbers
  1.  B::operator()();
  2.  
Nov 23 '06 #2
sivadhas2006
142 100+
Please help:

class B {
public:
void operator()(){ cout<<"in B()"<<endl;}
};

class D : public B {
public:
void operator()() {
B:: (); // compiler would error: expected unqualified-id before ‘(’ token
cout<<"in D()"<<endl;
}
};

How do I invoke base class function operator from derived class function operator? Thanks
Hi,

I used different operator to make it work.

Expand|Select|Wrap|Line Numbers
  1.  
  2. class B 
  3. {
  4.    public:
  5.  
  6.       void operator+ ()
  7.       { 
  8.          cout<<"in B()"<<endl;
  9.       }
  10. };
  11.  
  12. class D : public B 
  13. {
  14.    public:
  15.  
  16.       void operator +() 
  17.       { 
  18.          B::operator +(); 
  19.          cout<<"in D()"<<endl;
  20.       }
  21. };
  22.  
  23.  
Regards,
M.Sivadhas.
Nov 23 '06 #3
sivadhas2006
142 100+
Replace

Expand|Select|Wrap|Line Numbers
  1.  B:: (); // compiler would error: expected unqualified-id before ‘(’ token
  2.  
with

Expand|Select|Wrap|Line Numbers
  1.  B::operator()();
  2.  
Hi,

I tried
Expand|Select|Wrap|Line Numbers
  1.  B::operator()();
  2.  
That also working.

Regards,
M.Sivadhas.
Nov 23 '06 #4
abcpp
4
Replace

Expand|Select|Wrap|Line Numbers
  1.  B:: (); // compiler would error: expected unqualified-id before ‘(’ token
  2.  
with

Expand|Select|Wrap|Line Numbers
  1.  B::operator()();
  2.  

Thank you so much!!!
Nov 23 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Bob | last post by:
This seems to me like it should work but I get "generic" no matter which button I click. Javascript is not one of my better languages. Can the experts here take a look at this and tell me what I'm...
3
by: Matt | last post by:
Hello, I'm trying to implement the design below. I'd prefer to use commented operator+() in class Number instead of the associated, uncommented operator+(), but as I understand Covariant Return...
11
by: apex | last post by:
Hi All : How to override the class operator = like C++ ? Best regards !
1
by: Patrick De Ridder | last post by:
Is it possible to change this function into a string override? So I could just say d.ToString() Patrick private string reformat(double d) { NumberFormatInfo nfi = new...
2
by: Shark | last post by:
Hi, if we need to change the behavior of operator new, it is called overriding or overloading? My other question is, if we change the behavior of operator new, do we use malloc to do that or we use...
2
by: Jason Huang | last post by:
Hi, In my C# Windows form MyForm, it has a function MyFunction which is a big function and has lots of codes. I am thinking the override for MyFunction, one MyFunction has a parameter which...
5
by: meng.frank | last post by:
If I want to use std::vector or std::list for my class MyNewClass, which operators should I override? Maybe operator new and operator delete? If I want to use MyNewClass in std::set or std::map,...
2
by: Ben Voigt | last post by:
I have a function that is called for several distinct reasons. It is conceivable that a subclass would want to handle those cases differently. Therefore, what I want to do is have multiple v-table...
52
by: Jim Langston | last post by:
I wanted to do an operator override for but couldnt' figure out the syntax. I tried this (code that doesn't compile commented out with //: class CMyBitmap { public: CMyBitmap( int Rows, int...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.