473,385 Members | 1,593 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,385 software developers and data experts.

nested classes and multiple files

I have a (largish) "master" header file (>130 loc). I also have a number
of seperate "satelite" header files which declare various objects used
by the object declared in the "master" header file. In a clean design,
these "satelite" objects (i.e. declared in the satellite header files),
should really be nested classes within the master file.

However, if I was to put all the declarations in one massive file, it
will easily exceed 1000 lines in the one header file.

My question is that is the anyway that I can change these satilite
object declarations into nested class declarations (I tried
MasterClass::myClass {...}; but the compiler complained that MyClass was
not a member of MasterClass - that makes sense anyway). Long story short
- can I maintain the satellite (smaller) header files and one master
header file, whilst changing the satellite objcet declarations to nested
classes (nested within the master class).

Any help will be much appreciated. MTIA

Jul 23 '05 #1
2 9402
Alfonso Morra wrote:
[..]
My question is that is the anyway that I can change these satilite
object declarations into nested class declarations [..]


Well, yes. You can declare the nested class in the main class definition
and then define it later, say, in a separate header:

---------------------- outer.h
class outer {
public:
class inner;
};
---------------------- inner.h
class outer::inner {
int a;
};
---------------------- main.cpp
#include "outer.h"
#include "inner.h"

int main() {
outer o;
outer::inner oi;
}
----------------------------------

V
Jul 23 '05 #2


Victor Bazarov wrote:
Alfonso Morra wrote:
[..]
My question is that is the anyway that I can change these satilite
object declarations into nested class declarations [..]

Well, yes. You can declare the nested class in the main class definition
and then define it later, say, in a separate header:

---------------------- outer.h
class outer {
public:
class inner;
};
---------------------- inner.h
class outer::inner {
int a;
};
---------------------- main.cpp
#include "outer.h"
#include "inner.h"

int main() {
outer o;
outer::inner oi;
}
----------------------------------

V


Many Thanks Victor

Jul 23 '05 #3

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

Similar topics

9
by: Aguilar, James | last post by:
I know that one can define an essentially unlimited number of classes in a file. And one can declare just as many in a header file. However, the question I have is, should I? Suppose that, to...
3
by: Rubén Campos | last post by:
Organizing classes, types, structures, enums and whatever other entities into nested namespaces requires to include into every header and implementation file the complete path of namespaces. Let me...
7
by: Alfonso Morra | last post by:
I have a class that contains a nested class. The outer class is called outer, and the nested class is called inner. When I try to compile the following code, I get a number of errors. It is not...
3
by: Luis Diego Fallas | last post by:
Hi everyone , I'm having a problem when trying to compile code that contains the following pattern: using System; public class A { public class B : Inn.C { }
11
by: C# Learner | last post by:
Is it not possible to declare a nested class in a seperate file from its "parent" class -- i.e. in a similar way to the idea of spreading namespaces over more than one file?
8
by: Robert W. | last post by:
I've almost completed building a Model-View-Controller but have run into a snag. When an event is fired on a form control I want to automatically updated the "connnected" property in the Model. ...
1
by: =?Utf-8?B?SmVyZW15X0I=?= | last post by:
I am working on an order entry program and have a question related to deserializing nodes with nested elements. The purchase order contains multiple line items which I select using an...
3
by: | last post by:
I'm seeking (probably basic) guidance on the right way to split a large site that's supposed to represent one domain(mydomain.org) into many small VS.NET projects, and how to avoid issues with...
4
by: henry | last post by:
Folks: Using Dreamweaver CS3... Consider a home page, "index.php" which conditionally REQUIREs one of 'N' HTML files of pure content. All site styles are specified in a master CSS file,...
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...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...

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.