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

what is better?

hello,
I have a question regarding how to include classes .
Assuming I have a class called

class paraClass
{
enum eType { eOne, eTwo, eThree };
enum cValue = 4;
static convertToString (int inNumber) { ...}
static convertToNumber (int inString) { ...}

}

now in parent class, which option is better?

1.
class newClass : public paraClass
{
public:
int getValue() const { return myValue * cValue; }
private:
int myValue;
}
2.
class newClass
{
public
int getValue() const { return myValue * (paraClass::cValue);
private
int myValue;
}

Nov 30 '06 #1
3 1499

an*****@yahoo.com wrote:
hello,
I have a question regarding how to include classes .
Assuming I have a class called

class paraClass
{
enum eType { eOne, eTwo, eThree };
enum cValue = 4;
static convertToString (int inNumber) { ...}
static convertToNumber (int inString) { ...}

}

now in parent class, which option is better?

1.
class newClass : public paraClass
{
public:
int getValue() const { return myValue * cValue; }
private:
int myValue;
}
2.
class newClass
{
public
int getValue() const { return myValue * (paraClass::cValue);
private
int myValue;
}
Even assuming you modify paraClass to make its members protected
(rather than private) to give the derived class access (and you'd
better give it a protected destructor too just in case), in what way is
a newClass a "type of" paraClass?

It might depend what you are going to use it all for - are you going to
use paraClass for meta-programming because it's useful for that (you
might have another class that has the same names but with different
definitions. You can pass such classes into templates).

Generally inheritance should be used to implement a "is a type of"
design feature and I don't see how that applies above.

Nov 30 '06 #2
thanks for your answer. problem (which was not obious from example) is
that I am using paraClass static members/functions lot in my newClass.
So I thought I will be better of makeing newClass with paretn
paraClass. May be give me performance advantage, does it?

also, what is mata-programming?

Nov 30 '06 #3
an*****@yahoo.com wrote:
I have a question regarding how to include classes .
Assuming I have a class called

class paraClass
{
enum eType { eOne, eTwo, eThree };
enum cValue = 4;
static convertToString (int inNumber) { ...}
static convertToNumber (int inString) { ...}

}
Dump the above as a class. Make it a namespace instead.

--
To send me email, put "sheltie" in the subject.
Nov 30 '06 #4

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

Similar topics

52
by: Tony Marston | last post by:
Several months ago I started a thread with the title "What is/is not considered to be good OO programming" which started a long and interesting discussion. I have condensed the arguments into a...
220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
54
by: Brandon J. Van Every | last post by:
I'm realizing I didn't frame my question well. What's ***TOTALLY COMPELLING*** about Ruby over Python? What makes you jump up in your chair and scream "Wow! Ruby has *that*? That is SO...
226
by: Stephen C. Waterbury | last post by:
This seems like it ought to work, according to the description of reduce(), but it doesn't. Is this a bug, or am I missing something? Python 2.3.2 (#1, Oct 20 2003, 01:04:35) on linux2 Type...
2
by: Li Daobing | last post by:
Hello, Does anyone know what's the meaning of Dutch in "The Zen of Python"? Thanks in advance Li Daobing The Zen of Python, by Tim Peters
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
22
by: Alper AKCAYOZ | last post by:
Hello Esteemed Developers and Experts, I have been using Microsoft Visual C++ .NET for 1 year. During this time, I have searhed some topics over internets. Most of the topics about .NET is...
28
by: john_sips_tea | last post by:
Just tried Ruby over the past two days. I won't bore you with the reasons I didn't like it, however one thing really struck me about it that I think we (the Python community) can learn from. ...
19
by: Martin | last post by:
Hi all, We have an administrative application that we are considering to rewrite in aspx with vb2005. I think the marketing possibilities are enourmous. In our standard app, the user logs in...
49
by: Zach | last post by:
After having taken a looong break from VB (last used 6.0), I started getting back into programming again, this time with VS 2005. I began reading up on VB.NET from various sources (books,...
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: 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
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.