Questions about C++, a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language.

learn more… | top users | synonyms

2
votes
2answers
2k views

Interview question “What is virtual function” [closed]

It was funny for me, and I'm interesting the reaction for this question of the community. It was interview for C++/Qt developer, and question was asked "What is virtual function". Not something like ...
4
votes
4answers
476 views

Good unit-testing story for a unit test training [closed]

I have to advise a training on unit testing in my company. I would like to show a striking, real-life example of an unexpected regression not caught by compilation (of course) but detectable with ...
2
votes
3answers
6k views

Moving from C# to C++, and tips? [closed]

I've been using C# for a while now, and for the sake of furthering my career and extending my knowledge of programming, I want to get into C++. C# is very useful, and fast to work with, but since my ...
2
votes
2answers
267 views

How do I get rid of cyclic references in this design?

I have 3 classes: Meeting, Project and Agenda. A Project contains all sort of information + a list of meetings. The Agenda contains a list of upcoming Meetings. A Meeting contains some data + a list ...
0
votes
2answers
356 views

Risks of maintaining codebase C++ Builder 6? [closed]

My company has a large software application written in C++ Builder 6. I am a junior developer only one year out of college. My question is: How much technical debt are they in? What are the ...
2
votes
3answers
626 views

How can I effectively manage long-term feature development and short-term bug fixing at the same time?

We have a huge C, and C++ code base. There is a plan to add a new feature into the existing system, but, this should happen only after 3 to 4 months. So, we are looking for best possible options. ...
2
votes
1answer
180 views

Design of interface for finding one of something or a list

I am developing a telephony call model and thinking about how best to design the interface. One basic idea is that a call has a unique call identifier. I have a list of calls and finding a specific ...
24
votes
5answers
14k views

Best practices for using namespaces in C++ [closed]

I have read Uncle Bob's Clean Code a few months ago, and it has had a profound impact on the way I write code. Even if it seemed like he was repeating things that every programmer should know, ...
10
votes
3answers
1k views

Is it possible to compile a higher level language to readable C++? [closed]

C++ is a great language in many ways, but some things in particular are cumbersome to write without an IDE. As a VIM user, it would be very interesting if I had access to a higher level language which ...
0
votes
2answers
3k views

How would I make a compiler in C++? [closed]

This probably been asked for but I can't google "How to make a compiler in C++" because I will just get "How to compile C++" as the results. Anyway, for my question, I'd like to make a simple ...
0
votes
1answer
1k views

Best way to quickly explore/grok open source C/C++ projects? [duplicate]

I'm looking for a suggested workflow for quickly being able to download various c/c++ open source projects and then begin intelligently navigate sources. "Intelligently" means being able to jump ...
16
votes
8answers
20k views

What is the best C++ source code to read for a beginner? [closed]

I'm trying to improve my c++ coding technique by reading c++ source code. Which open source project would you recommend? Is the code of Boost C++ Libraries a good one?
21
votes
4answers
766 views

C++ Linkage Languages other than C?

The C++ language allows intermixing of both C++ and C in one source file. For example, extern "C" { struct bar { /* ... */ } } Does C++ or has it ever supported any other "linkage languages" ...
18
votes
4answers
1k views

Is there a measure of code rot? [duplicate]

I'm dealing, again, with a messy C++ application, tons of classes with confusing names, objects have pointers into each other and all over, longwinded Boost and STL data types, etc. (Pause and ...
8
votes
2answers
10k views

Open source projects, how to choose?

I would like to join an open source project since I think I am good enough at programming to progress onto reading others code and to modify it. But the problem is, how would I choose an open source ...
10
votes
4answers
68k views

What popular program is used to develop GUI in C++? [closed]

I'm asking this question because my creativity can only go so far with console programs in C++. I need to know what program/software the majority of c++ software developers out there use develop GUI ...
1
vote
2answers
678 views

Without C++-like destructors, how do we return resources that aren't managed by garbage collector in Java? [duplicate]

I'm in a job hunting. And in my CV I placed a skill list like: Skills: C/C++/Java/... The most common question I got is: "hem, since you are familiar with both C++ and Java, can you tell some ...
1
vote
2answers
1k views

What is the exact syntax of inline?

CASE 1 (Definition and declaration in same source file) Suppose both my prototype and definition of global function is in .cpp file. Where should I write inline keyword to make compiler know? In ...
2
votes
2answers
359 views

How to improve in code after you know many languages? [closed]

Over the past years I learned about 14 programming languages (assembler phyton delphi qbasic c++ c# ruby perl - etc etc etc). However this was all out of my own interest, I didn't went to school ...
0
votes
3answers
1k views

What are the good practices for including namespaces in C++ that avoid more typing?

I am starting out with C++ and almost everywhere I see there is these 2 sentences at the top. #include <iostream> using namespace std; As I understand namespaces are something to keep names ...
4
votes
2answers
2k views

C++ class with only pure virtual functions: what's that called?

So i'm looking for some input/consensus on what terminology we should be using to describe something that looks like this: class Printable { public: virtual void printTo(Printer *) = 0; ...
34
votes
3answers
13k views

How could the first C++ compiler be written in C++?

Stroustrup claims that Cfront, the first C++ compiler, was written in C++ (Stroustrup FAQ). However, how is it even possible that the first C++ compiler be written in C++? The code that makes up the ...
4
votes
2answers
417 views

Using absolute paths for build dependencies

Currently we are using Source Safe and have started migration to Subversion. All of our external SDK's(> 500 MB) are held in Source Safe right now, and I am looking for ways to move them from VSS to a ...
9
votes
2answers
2k views

C++ Commitee Members? [closed]

I have been searching the web for information regarding what people (and their backgrounds) are in the C++ commitee. However, to my surprise I have not found any such information. Where can I find ...
-2
votes
3answers
231 views

What does the static keyword do here? [closed]

Can anyone explain this piece of code? CODE1 int &fun() { static int x = 10; int &b =x; return b; } int main() { fun() = 3; cout << fun(); return 0; } Output: ...
3
votes
2answers
359 views

Could I GPL this code?

I'm working on reviving a C++ codebase that hasn't been touched since '97. It's academic software for text analysis, and originally it was non-functional, it wouldn't even compile. I fixed the code ...
-3
votes
1answer
140 views

How do you call the discipline which consist of making the right choice of language/paradigm/class diagrams? [closed]

As a physicist, I've learnt programming on my own. But I would like to know the name of the discipline (like algorithmics is the discipline of designing algorithms) which consists of : making the ...
6
votes
2answers
1k views

In C++, were SFINAE and metaprogramming intentional or just a byproduct of templates?

SFINAE and template metaprogramming can do wonderful things and many libraries also use them considerably. Historically both of these "magic concepts" were intentionally introduced/supported in C++ ? ...
3
votes
3answers
626 views

Alternative inheritance paradigms in object-oriented design

My apologies if a variation of this question has been asked before, but due to its nature it is hard to search for. I am having a discussion with a colleague about object-oriented design, and it ...
34
votes
2answers
7k views

Why are reference-counting smart pointers so popular?

As I can see, smart pointers are used extensively in many real-world C++ projects. Though some kind of smart pointers are obviously beneficial to support RAII and ownership transfers, there is also a ...
3
votes
3answers
4k views

How to initialize all your references?

I have recently taken a project with another developer, and he has a certain way of initializing his references. class Player { private: Console &console; Armor &armor1, ...
0
votes
1answer
443 views

Reading a specific type of input from file

I have a software that reads from a file. Each object in the software takes 7 inputs viz. string string string float string float int I have an input file. It contains a number of input values. If ...
4
votes
1answer
385 views

Is using protected inheritance to hide (but exploit) implemented interface from the public ok?

Recently, we had a discussion about code using protected inheritance in order to hide the fact (to client code) a class inherits from a specific base class but to exploit this fact in the ...
19
votes
2answers
2k views

Is it a good idea to provide different function signatures that do the same thing?

Here is a C++ class that gets constructed with three values. class Foo{ //Constructor Foo(std::string, int, char); private: std::string foo; char bar; int baz; }; All of ...
0
votes
1answer
148 views

Overloading to support multiple related types (especially pointers)

Problem I was just trying to debug a set of file-manipulation routines I wrote for a program I am working on. One of them kept returning an INVALID_HANDLE error. Explanation I figured out what the ...
2
votes
1answer
183 views

Adding explicit interfaces to Legacy managed C++ code

I have a bit of a challenge and I am not sure how to approach this. We have a very very large project (that is about 5 years old). The code base is HUGE so a full refactor is out of the question. ...
1
vote
4answers
5k views

changing value of a private member of a class in c++ without using member or friend function

Using pointer, I am able to modify the private value of the class in the code below. Does it violate the C++ concept that private member can only be modified by member or friend functions? ...
5
votes
2answers
611 views

First of the The Ten Commandments for C++ Programmers by Steve Oualline correctly transcribed?

I do not have the book “Practical C++ Programming” by Steve Oualline but I was reading his Ten Commandments for C++ programmers at ...
2
votes
6answers
2k views

Learning good OOP design and unlearning some bad habits [duplicate]

Possible Duplicate: What books or resources would you recommend to learn practical OO design and development concepts? I have been mostly a C programmer so far in my career with knowledge ...
4
votes
4answers
3k views

Why isn't it possible to switch between header and cpp in Visual Studio? [closed]

For the last eight years I wait for Microsoft to add the basic C++ functionality of switching back and forth between .h and .cpp files, and it keeps astonishing me it is still not supported in Visual ...
6
votes
4answers
20k views

How can I get into C++ graphics library? [closed]

I have been programming for a year so far and I know 2 languages: C and C++. I've covered the basics, I've written functional windows programs, and I've written complicated bits of code. When I was ...
1
vote
2answers
830 views

log4cxx: is it a stable option to include as part of distributed library? [closed]

We are porting our Java API library to C++. (Our target platforms are Linux and Windows.) Since we have minimal C++ experience, the learning curve has been pretty steep, but overall we have been able ...
0
votes
1answer
197 views

How we call an RPC that not only calls external functions but also updates data structures?

I have a simple C++ RPC that lets you have remote class instances that support live members (data structures) update as well as method calls. For example I had a class declared like this (pseudocode): ...
17
votes
7answers
2k views

Does modular programming affect computation time?

Everyone says that I should make my code modular, but isn't it less efficient if I use more method calls rather than fewer, but larger, methods? What is the difference in Java, C, or C++ for that ...
3
votes
2answers
1k views

What is the best solution for static memory allocation?

I'm working on image processing and I need to use big Images in a critical system. A good practice for critical systems is to avoid dynamic allocation of memory but what is the design/recommendations ...
3
votes
1answer
118 views

Ported Functions Licensing

I have found several functions in python 2.7.2 to be very useful and I recreated them in C++ for my own uses. How do I properly give python credit for them? Do I even have to? I never actually looked ...
4
votes
2answers
719 views

Learning YACC nowadays, does it make sense? [closed]

I have a huge project that is using YACC and I would need to fix a bug in it. I might ask someone else who wrote that to fix it but I'm interested in how compilers work. Does it make sense to learn ...
4
votes
2answers
1k views

Java naming conventions vs. C++/C naming conventions

I am a Java developer who is starting to pick up more and more C++/C (yes I know they're different, bear with me). One thing that struck me as odd was the different naming conventions used by these ...
1
vote
5answers
1k views

Starting with 3D programming [closed]

I will be working on a 3D project and i need to learn c++ and opengl fast. as i have heard it is the best combination to do graphics. I would also like your recommendation on this book I came ...
2
votes
1answer
250 views

How can I distinguish between one-worded expressions and two-worded expressions?

I was told to create two lists concerning most frequently used words from a plain text (10 Mb arbitrary texts) as monograms (for single worded expressions such as human, water, is) and bigrams (for ...