473,320 Members | 1,861 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.

Seperating Definition and Declaration of a class

As all we know, in order to remove cyclic includes in C++ we seperate
the declarations and definitions of classs and it's member in two files
Header (*.h) and source files (*.cpp). This is not a problem for C# as
there is no concept of include.

I faced problems for seperating declarations and definitions for class
when it contains [default]properties. This can also be done in context
of struct/structures. Here is how we can.

Class A

--------------------------------------
FILE : A.h <-- contains only declarations
--------------------------------------
namespace Ankit
{
public class A
{
private:
int mapData;

public:
property int Height ; // no need for definitions in A.cpp
property int Width ; // no need for definitions in A.cpp
property ArrayList^ Points
{
ArrayList^ get();
}
property double Zoom
{
double get();
void set(double level);
}
property int default[int]
{
int get(int index);
}

A();
void Load(double level);
}
}
--------------------------------------
FILE : A.cpp <-- contains implementaions
--------------------------------------
Note:- No need to write access specifiers again

namespace Ankit
{
ArrayList ^ A::Points::get()
{
return this->wayPoints ; // your implementations
}

double A::Zoom::get() // get set functions should be written
seperate
{
return 1.0;
}

void A::Zoom::set(double l)
{
;
}
int A::default::get(int index)
{
// your implementations
return this->wayPoints[index];
}
///<summary>
///Default Constructor
///</summary>
A::A()
{
// your implementations
}

void A::Load(double level)
{
//implementations
}
}
}

That's all.

Hope this may be usefull to u....

Regards.....

Ankit Jain
[Developers Have Their Own Gods]

Nov 17 '05 #1
0 963

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

Similar topics

7
by: CoolPint | last post by:
I read that there has to be only one definition of classes, functions, etc. in a project. I just realized I might have broken the rule by defining the exception classes in the header file. But...
3
by: DanielBradley | last post by:
Hello all, I have recently been porting code from Linux to cygwin and came across a problem with static const class members (discussed below). I am seeking to determine whether I am programming...
8
by: newmans | last post by:
Perhaps one of the experts can straighten me out on this point... In Bjarne Stroustrup's book 'The C++ Programming Language' 3rd Edition, section 4.9, indicates that typedef complex<short>...
14
by: Mike Hewson | last post by:
Have been researching as to why: <example 1> class ABC { static const float some_float = 3.3f; }; <end example 1>
19
by: J. J. Farrell | last post by:
After many years of dealing with definition and linkage issues in ways that I know to be safe, I've decided it's time to try to understand this area properly. Consider a header file with the file...
2
by: xllx.relient.xllx | last post by:
I have a few quetions about definitions vs declarations concerning defined types (user defined), specifically classes. From what I understand, a class contained in a header file is a definition as...
8
by: caferias | last post by:
Hello, I'm curious about the difference between the term "declaration" and "definition" in the context of XML. Where is the difference? Greetings: Fernando
9
by: Jess | last post by:
Hello, I was told that if I declare a static class constant like this: class A{ static const int x = 10; }; then the above statement is a declaration rather than a definition. As I've...
10
by: Danigan | last post by:
It's been about 4 years since I did much in C++. To see if I remembered anything, I made a new project, made a header file containing a class, included the header file from my main file, used...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
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...
0
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: 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.