472,984 Members | 2,168 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,984 software developers and data experts.

Including a (renamed) source file is ugly, right?

Hello, I recently saw code like this:

$ cat t.h
namespace nc{

template<typename T>
class Base {
T hello;

protected:
int test1;
};

template<typename T>
class Next: public Base<T>{

int test();
};
};

#include "t.tmpl"
$ cat t.tmpltemplate<typename T>
int nc::Next<T>::test(){
return test1;
}
I couldn't even get the code to compile until I'd changed return test1;
toreturn Base<T>test1;"t.tmpl" looks like a renamed source (.cpp) file and
it's used to work around the fact that the compilerlacks the export keyword
but the author still wantsto hide the implementation details. I
immediatelythought this was ugly indeed, was I right? If so, why?/ Eric
Jul 23 '05 #1
3 1218
oops, sorry, I don't know what happened to my line breaks.

/ Eric
Jul 23 '05 #2

"Eric Lilja" <mi****************************@gmail.com> wrote in message
news:d4**********@news.island.liu.se...
Hello, I recently saw code like this:

$ cat t.h
namespace nc{

template<typename T>
class Base {
T hello;

protected:
int test1;
};

template<typename T>
class Next: public Base<T>{
You really want the following to be a private member?
int test();
};
};
No semi-colon required above.
#include "t.tmpl"
$ cat t.tmpltemplate<typename T>
int nc::Next<T>::test(){
return test1;
Change the above to:

return this->test1;

or

return Base<T>::test1;

For more details on why you need to do this, see:
http://www.parashift.com/c++-faq-lit...html#faq-35.12
}
I couldn't even get the code to compile until I'd changed return test1;
toreturn Base<T>test1;"t.tmpl" looks like a renamed source (.cpp) file and
return Base<T>::test1;
//you missed the "::" part
it's used to work around the fact that the compilerlacks the export
keyword but the author still wantsto hide the implementation details. I
immediatelythought this was ugly indeed, was I right? If so, why?/ Eric


Personally, I find it ugly too. But the lack of an export keyword in most
compilers is the reason why people have to do this (or something similar to
this).

You may also find Q7 to Q9 helpful:
http://www.parashift.com/c++-faq-lite/templates.html

Regards,
Sumit.
--
Sumit Rajan <su*********@gmail.com>
Jul 23 '05 #3

"Sumit Rajan" <su*********@gmail.com> wrote in message
news:3d*************@individual.net...
But the lack of an export keyword in most compilers


Let me try to rephrase that:

But the fact that most compilers have not (yet) implemented support for the
export keyword ...

Regards,
Sumit.
--
Sumit Rajan <su*********@gmail.com>
Jul 23 '05 #4

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

Similar topics

1
by: Andres Baravalle | last post by:
Hi, I am quite new with python and I'm developing a package that is including a binary file (eggtrayiconmodule.so) that is open source. My software is developed in part under linux, and now I...
115
by: TheAd | last post by:
At this moment I use MsAccess and i can build about every databound application i want. Who knows about a serious open source alternative? Because Windows will be a client platform for some time, i...
6
by: Al-Burak | last post by:
I have a class which only purpose is to provide services to a variety of classes in other files. The 'manipulator' class is aware of the other classes only because the header files have been...
8
by: david.lindsay.green | last post by:
Hello all, I am quite new a web scripting and making web pages in general and I have stumbled across a problem I have as yet been unable to solve. I am trying to take the contents of a textarea box...
10
by: Ben Sehara | last post by:
Hi, I want to include three php files in index.php file like the code below. But it always shows up only two, any two of the three, any order. <tr> <td><?php include...
7
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
I'm new to Visual Studio 2005. I'm creating a windows application using Visual Basic. After I added a control to a form and added some codings to the control, I want to rename the control. ...
2
by: abujarour | last post by:
Hi, I am working on a c++ project. I want to define my own classes. I define each class in a separate header file, and define the body of its methods in another source cpp file. For example:...
8
by: squaretriangle | last post by:
Regarding either of the following: 1. Including a .c file with #include, 2. Including source code contained in a .h header file with #include I have 2 questions. 1. Is the reality of most...
2
by: Cameron.MacNeil.024 | last post by:
Hi folks, hopefully I posted this question in the right place. I'm currently writing an html file which references three different xml files, each one with its own xsl stylesheet. Originally I...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.