473,385 Members | 1,693 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.

includes

20
Hi,

How do I properly include classes that are dependable of each other, without getting an error that the compiler don't knoe anything about one of the classes?
Ex:

vector.h
Expand|Select|Wrap|Line Numbers
  1. class Vector
  2. {
  3.      public:
  4. ...
  5.     Vector operator*(const Matrix& m) const;
  6. }
matrix.h
Expand|Select|Wrap|Line Numbers
  1. class Matrix
  2. {
  3. ...
  4.        Vector operator* (const Vector& v) const;
  5. }
thanks
May 29 '08 #1
2 1193
arnaudk
424 256MB
Don't include vector.h in matrix.c/matrix.h because then you will get interdependency errors.... Instead, if you don't call methods/members of vector in matrix, you only need to tell the compiler in matrix.h that there exists a class class vector, without fleshing out the details (and vice-versa for vector.h):
Expand|Select|Wrap|Line Numbers
  1. //vector.h:
  2. class Matrix; // declaration only: Matrix is a class
  3. class Vector
  4. {
  5.      public:
  6.     Vector operator*(const Matrix& m) const;
  7. }
  8.  
  9. //matrix.h:
  10. class Vector; // declaration only: Vector is a class
  11. class Matrix
  12. {
  13. ...
  14.        Vector operator* (const Vector& v) const;
  15. }
  16.  
May 29 '08 #2
madshov
20
Yes of course! Now I see. Thanks for clarifying.
May 29 '08 #3

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

Similar topics

13
by: Tim Tyler | last post by:
A fairly simple question: I have a library A which depends on library B and C. Currently I have: <?php include("A.inc.php"); include("B.inc.php"); include("C.inc.php");
2
by: Joe Mowry | last post by:
First off, I'm posting this question for a friend that doesn't have access to the news groups. Problem: Using PHP as the base and has several PHP < includes > for various functions, all this...
4
by: Patrick | last post by:
I have an ASP site with about 50 ASP files, all of which are currently including a common "includes.asp" file near the top of the file, responsible for generating the <HEAD/> section of the HTML ...
4
by: Generic Usenet Account | last post by:
I am seeing some unexpected behavior while using the STL "includes" algorithm. I am not sure if this is a bug with the template header files in our STL distribution, or if this is how it should...
2
by: David Muoio | last post by:
I am trying to validate an XML file against an XSD that is stored in the assembly as an embedded resource. I can get it to work as long as the XSD does not include other XSDs. After a fair amount...
12
by: tshad | last post by:
I am not sure why I am getting this error: I have the following code I want to run from another include file that holds all my functions. functions.inc...
6
by: William F. Zachmann | last post by:
We've got a project going that involves moving an old web site with a massive dll written in C++ that produces most of the output from a SQL 7.0 data base on NT4 onto IIS on Windows 2003 Server...
3
by: Jeff | last post by:
I have an asp page. Now I know this is sortof OT, but I am not sure of the forum to get an answer. I have an include on this asp page <!-- #include file=\forum\includes\consts-inc.asp --> ...
4
by: Ron | last post by:
Hi all, Trying to work out a few problems in using php on my site. Partially this is a html question. I was reading a lot of the posts and it seems that some of the includes people are using are...
1
by: JRough | last post by:
I have includes at the top of the file and I have inline includes also includes in mysql queries. For example: include './includes/config.inc.php'; include $include_path.'dates.inc.php';...
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...
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: 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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...

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.