Great. I and my open source project thank you all for your help.
Type: Posts; User: skewray
Great. I and my open source project thank you all for your help.
Would this be considered good coding practise? Seems like a very clever way to make unmaintainable code.
The fundamental problem was that I assumed that when the compiler saw "*T = *X", it would magically know, through polymorphism, that X was an "intersection" and use X's copy semantics. Since the...
The history of this is that I have code that works fine, except that there is one polymorphic function that has identical code for every subclass. I am trying to refactor and put the code into...
I have noticed that when using the default copy assignment for a virtual polymorphic class, I do not get the behaviour I expect. Although copy assignment of the derived class works fine, copy...
Thanks, laserlight. Id did have a stupid type on there. What I originally couldn't get working was when the class is itself a template:
template <int N>
class myclass
{
public:
...
I want to have a template function that is a member of a class. Is this possible? This code snippet is how I would think the syntax would go, although it doesn't compile. How would I achieve the...
Thanks, that definitely works. I never would have come up with the syntax, although now that I've seen it, I understand where it comes from.
Brian
If I wanted to count how many objects of a class I make, I could write
// header.hh
class bob
{
public:
bob() ;
private:
I assume that since I can figure out that it is a typename without the help of the extra keyword, this means that the compiler parser needs more than one token of look-ahead in order to figure out...
That works much better. Thanks, although I actually don't understand what the addition of the typename keyword does.
Wouldn't returning a reference to a vector then be implementation dependent? ...
I am trying to add an iterator to a class template. The class is not much more than an encapsulated standard library vector, which some added features. The compiler chokes pretty hard on the...
Ah, that works much better. Thanks! I used to use ar, but I decided I wanted to simplify my build procedure by having each subdirectory make one object file, and then combine those at the top...
I want to take all of the C++ object files in a directory and ball them up into one object file.
I tried "g++ -r -o out.o in_1.o in_2.o ...", but I get the error message "/usr/bin/ld: cannot find...
Instituting binary search, please wait... -Wunreachable-code. Here is the manual entry on it:
-Wunreachable-code
Warn if the compiler detects that code will never be executed.
...
Fog is lifting here. The construction you give rings a bell.
So the only remaining question is, what do all of these other warnings mean, and how do I know that I can ignore them in the future? ...
The answer is yes, but it will take more lines of code than you expect. You create a class with the basic type you are modifying as a private member, and then add all the functionality you want to...
Hello! I am using gcc 4.1.2 to compile the following code. The base class just makes sure that freed instances are not referenced, and might warn of wild pointers. The label is just a derived...
Great recommendations! I was looking for more leads into good books.
My ultimate motivation for asking is less performance than learning C++. I just read "Design Patterns" by Gamma et al., and I found most of the patterns incomprehensible, except for the few I had...
The motivation for my question was that I have read that using RTTI is inherently slow. I haven't done actual runtine comparisons, though; runtime may be compiler dependent anyway. The alternate...
I have a polymorphic set of classes, and I want to have a virtual comparison function. Right now each of the derived classes has a function that looks something like this:
bool...
"double C = 261.626 * 2;" is not the best programming style. "261.626" is a completely arbitrary number. Better is:
double A1 = 440.0; // standard...
Well, I still haven't found this forum, but I'm going to keep looking...
C++ for C Programmers by Pohl is a dog. Each edition is worse that than the previous.