My Most Important C++ Aha Moments (2006)
artima.com
My Most Important C++ Aha Moments (2006)
1–10 of 84 posts
Re: My Most Important C++ Aha Moments (2006)
#2Re: My Most Important C++ Aha Moments (2006)
#3Is that common among programmers?
Re: My Most Important C++ Aha Moments (2006)
#4I love C and Objective-C. I can't stand C++. Is that common among programmers?
Re: My Most Important C++ Aha Moments (2006)
#5Yep the beauty (and maybe curse) of C++ iterators is that they are a faithful abstraction of pointers.
Re: My Most Important C++ Aha Moments (2006)
#6I love C and Objective-C. I can't stand C++. Is that common among programmers?
// file: A.h
class A {
B* _b;
};
// file: B.h
class B {
A* _a;
};
I mean a pointer has a fixed size, so couldn't the compiler just leave some sort of type placeholder in class A until class B is eventually defined.Re: My Most Important C++ Aha Moments (2006)
#7I love C and Objective-C. I can't stand C++. Is that common among programmers?
What has always bugged me about C++, but maybe I am overlooking some reason why this generally cannot work, is that it does not resolve circular dependencies such as this one: // file: A.h class A { B* _b; }; // file: B.h class B { A* _a; }; I mean a pointer has a fixed size, so couldn't the compiler just leave some sort of type placeholder in class A until class B is eventually defined.
// file: A.h
class B;
class A {
B* _b; // or any of the other variants.
};Re: My Most Important C++ Aha Moments (2006)
#8Earlier quoted context omitted.
What has always bugged me about C++, but maybe I am overlooking some reason why this generally cannot work, is that it does not resolve circular dependencies such as this one: // file: A.h class A { B* _b; }; // file: B.h class B { A* _a; }; I mean a pointer has a fixed size, so couldn't the compiler just leave some sort of type placeholder in class A until class B is eventually defined.
This can be done, check the end of this answer: http://stackoverflow.com/a/628079/429972 // file: A.h class B; class A { B* _b; // or any of the other variants. };
class A {
class B* _b;
};Re: My Most Important C++ Aha Moments (2006)
#9I love C and Objective-C. I can't stand C++. Is that common among programmers?
RAII and scope based construction/destruction is actually quite nice.
Re: My Most Important C++ Aha Moments (2006)
#10I love C and Objective-C. I can't stand C++. Is that common among programmers?