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

learn more… | top users | synonyms

5
votes
8answers
1k views

Why has the rate of programming language popularization slowed down in recent decades? [closed]

If I understand correctly, there was a huge birth of programming languages during the early decades of computing, but then things have stabilized. Basically, why are many universities and industries ...
3
votes
3answers
430 views

Specifics of Switch and If statements

Why do we need the switch statement if there is the if statement? Why can't we use several ifs like if(a==1) do this1; if(a==2) do this2; ... instead of switch (a) { case(1): {do ...
3
votes
5answers
4k views

Recommended books on C++ [duplicate]

Possible Duplicate: Is there a good book to grok C++? I'm looking for a book that contains a CDRom with a IDE for readers to install and use as a environment to learn C++ on. Like the ...
0
votes
1answer
134 views

How to reuse c++ code? [closed]

How do I call functions defined outside a source file given you shouldn't use header files? -- EDIT: generic(?) question below So, first, a problem should be broken down into simpler subproblems. ...
80
votes
13answers
7k views

Way in over my head! (Dealing with better programmers)

I've just been hired as a member of a group that is developing in C++. For the last 11 years, I'd been coding on and off at my last job (some C, some Fortran, some C++). The coding I'd done was ...
53
votes
14answers
8k views

Why would it ever be possible for Java to be faster than C++?

Sometimes Java outperforms C++ in benchmarks. Of course, sometimes C++ outperforms. See the following links: http://keithlea.com/javabench/ ...
78
votes
15answers
7k views

Why did memory-managed languages like Java, Javascript, and C# retain the `new` keyword?

The new keyword in languages like Java, Javascript, and C# creates a new instance of a class. This syntax seems to have been inherited from C++, where new is used specifically to allocate a new ...
29
votes
9answers
47k views

Comparison of IDEs for C++ and C development on Linux: KDevelop, Eclipse, NetBeans, CodeBlocks and Anjuta [closed]

I'd like to note your experience of full scale IDEs on Linux. I personally work mostly with vim, however other programmers would like to see a real IDE. So I'd like to hear your personal opinion ...
39
votes
12answers
2k views

Which C# practices should be avoided in C++?

I'm currently teaching myself C++. I'm very proficient at C#, and was wondering which common practices in C# can lead to difficulties in C++, and what a C++ programmer should do instead.
26
votes
8answers
4k views

Is the algorithm more important than the programming language?

During the current (2013) Google Code Jam contest, there was a problem that took C++ and Java people 200+ lines of code as compared to Python people that solved the same problem only using 40 lines of ...
18
votes
10answers
5k views

Why are pointers not recommended when coding with C++

I read from somewhere that when using C++ it is recommended not to use pointers. Why is pointers such a bad idea when you are using C++. For C programmers that are used to using pointers, what is the ...
36
votes
6answers
5k views

Good example of complex code using TDD [closed]

What would be a good example of the use of TDD in large, real-life, complex, projects? All the examples I've seen so far are toy projects for the purpose of a book or a paper... Can you name an ...
30
votes
6answers
10k views

Why does Facebook convert PHP code to C++?

I read that Facebook started out in PHP, and then to gain speed, they now compile PHP as C++ code. If that's the case why don't they: Just program in c++? Surely there must be SOME errors/bugs when ...
12
votes
6answers
6k views

What are the fundamental differences between C and C++? [closed]

Many tend to write "C/C++", as if they were the same thing. Although they share many similarities, they are clearly not the same. But what are really the fundamental differences between C and C++? Is ...
35
votes
15answers
10k views

If you need more than 3 levels of indentation, you're screwed?

Per the Linux kernel coding style document: The answer to that is that if you need more than 3 levels of indentation, you're screwed anyway, and should fix your program. What can I deduce ...
21
votes
16answers
21k views

What are some fun (and very easy) C++ programs for a 10 year old kid to write? [closed]

It might be a bit young to be learning C++, but I've been hired to tutor a ten year old and I will happily oblige! I'm struggling to think of some fun but easy programs to work on. Ideally, I'm ...
15
votes
3answers
2k views

Did C++11 address concerns passing std lib objects between dynamic/shared library boundaries? (ie dlls and so)?

One of my major complaints about C++ is how hard in practice it is to pass std library objects outside of dynamic library (ie dll/so) boundaries. The std library is often header-only. Which is great ...
2
votes
6answers
1k 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 ...
54
votes
16answers
2k views

Why should I care about micro performance and efficency?

Many questions and answers on the C/C++ pages, specifically or indirectly discuss micro performance issues (such is the overhead of an indirect vs direct vs inline function), or using an O(N2) vs ...
29
votes
2answers
2k views

How should C++ Unit Test code be organized for maximum Unit Test efficiency?

This question is not about Unit Testing Frameworks. This question is not about writing Unit Tests. This question is about where to put the UT code written and how/when/where to compile and run it. ...
11
votes
4answers
2k views

Why is sizeof called a compile-time operator?

Originally, this is a part of another question. Why is sizeof called a compile-time operator? Isn't it actually a run-time operator? And if it is indeed a compile-time operator, how does it help in ...
6
votes
4answers
1k views

Learning Python is good? [duplicate]

Possible Duplicate: Is Python worth learning? Is it a useful tool? Recently I have seen some videos from MIT on computer programming topics. I found it's really worth watching. Especially ...
19
votes
14answers
3k views

University teaches DOS-style C++, how to deal with it

Half a year ago I had a look at available programming educations. I chose this one because unlike most of the choices: The majority of the courses seemed to be about something concrete and useful; the ...
17
votes
4answers
12k views

what is message passing in OO?

I've been studying OO programming, primarily in C++, C# and Java. I thought I had a good grasp on it with my understanding of encapsulation, inheritance and polymorphism (as well as reading a lot of ...
13
votes
9answers
5k views

C++ for C# Developers

I know C# pretty well (self-taught, sadly) and need to do some C++ programming for a Windows application. I have been able to find a ton of information for C++ developers learning C# but haven't been ...
7
votes
6answers
3k views

What should I know about C++?

I've recently started learning C++, and I enjoy it a lot. I've often read it's easier to write bad code in C++ than in most languages, and that it is a lot deeper than what it seems. As I'd like to ...
20
votes
11answers
4k views

typedefs and #defines

We all have definitely used typedefs and #defines one time or the other. Today while working with them, I started pondering on a thing. Consider the below 2 situations to use int data type with ...
13
votes
10answers
8k views

How to master C++?

I am a grade 11 student and have Computer Science... I just love the subject.. We are doing C++ ... I have loadsss of interest in this subject ... I am kind of able to do the programs but would like ...
8
votes
3answers
532 views

C++ for Java Programmers

I am going to have a lecture about C++ for experienced Java programmers. Because C++ is a big language and I have just one lecture, I want to point out the most important "gotchas" and C++ features ...
8
votes
2answers
9k 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 ...
7
votes
7answers
1k views

Learning the nuances of a language (C++)

So I'm a recent college graduate, and I really enjoy working in C++; I worked with it a lot in school, and would like to pursue a career writing in C or C++. The problem I'm having is that I'm trying ...
50
votes
11answers
2k views

Why do we have postfix increment?

Disclaimer: I know perfectly well the semantics of prefix and postfix increment. So please don't explain to me how they work. Reading questions on stack overflow, I cannot help but notice that ...
20
votes
6answers
3k views

C++ Renaissance - marketing slogan? [duplicate]

Possible Duplicate: What does the latest “C++ Renaissance” mean? Lately, I hear a lot about C++ Renaissance. What is that? C++ is currently undergoing a renaissance. This ...
12
votes
5answers
4k views

Dependency injection ; good practices to reduce boilerplate code

I have a simple question, and I'm not even sure it has an answer but let's try. I'm coding in C++, and using dependancy injection to avoid global state. This works quite well, and I don't run in ...
12
votes
15answers
8k views

Why is C++ often the first language taught in college? [closed]

My school starts the computer science curriculum with C++ programming courses, meaning this is the first language that many of the students learn. I've seen that many people dislike C++, and I've ...
9
votes
8answers
5k views

How is C different from C++?

Many people have said that C++ is a completely different language than C, but Bjarne himself has said that C++ is a language that is extended from C hence that is where the ++ comes from. So why does ...
9
votes
21answers
4k views

Should I Learn C/C++ Even If I Just Want To Do Web Programming? [duplicate]

Possible Duplicate: I don't know C. And why should I learn it? My goal is to be able to create online apps and dynamic, database driven websites. For instance, if in the future I get ...
8
votes
3answers
1k views

Achieving forward compatibility with C++11

I work on a large software application that must run on several platforms. Some of these platforms support some features of C++11 (e.g. MSVS 2010) and some don't support any (e.g. GCC 4.3.x). I ...
8
votes
1answer
3k views

What is “friend” keyword used for?

Can you explain to me why the friend keyword is preferred for giving access rights to private data of class?
5
votes
4answers
6k views

Writing a lexer in C++

What are good resources on how to write a lexer in C++ (books, tutorials, documents), what are some good techniques and practices? I have looked on the internet and everyone says to use a lexer ...
4
votes
1answer
1k views

sqrt c# vs sqrt c++

An idea why the c# version of sqrt (System.Math.Sqrt) is ~10 times slower than c++ version ? Futhermore, C# version seems to have one extra digit of precision. I have run my test under MSVC2012. I ...
3
votes
4answers
664 views

What are the arguments for/against Code Generation?

I'm in a position where we've got some brittle code that constructs SQL-like queries via text concatenation with parameters for inputs. The data source that it queries is fast and scalable but lacking ...
18
votes
4answers
12k views

Why is #include <iostream.h> bad?

I was reading another thread where a guy asked about C++ books for beginners, and one of the programmers answering wrote this: Some warnings: avoid all books that present an "hello world" stating ...
17
votes
8answers
2k views

Why do books say, “the compiler allocates space for variables in memory”?

Why do books say, "the compiler allocates space for variables in memory". Isn't it the executable which does that? I mean, for example, if I write the following program, #include <iostream> ...
11
votes
7answers
2k views

Does C# give you “less rope to hang yourself” than C++? [closed]

Joel Spolsky characterized C++ as "enough rope to hang yourself". Actually, he was summarizing "Effective C++" by Scott Meyers: It's a book that basically says, C++ is enough rope to hang ...
11
votes
4answers
1k views

Object Oriented Programming: getters/setters or logical names

I'm currently thinking about an interface to a class I'm writing. This class contains styles for a character, for example whether the character is bold, italic, underlined, etc. I've been debating ...
11
votes
2answers
1k views

Best overview to modern C++ paradigms?

I used to write C++ extensively between 8 and 10 years ago. I have since moved on to C# for professional reasons. However, from time to time I see statements like "If you're still manually ...
9
votes
9answers
439 views

Studies on code documentation productivity gains/losses

After much searching, I have failed to answer a basic question pertaining to an assumed known in the software development world: WHAT IS KNOWN: Enforcing a strict policy on adequate code ...
7
votes
4answers
430 views

When to import names into the global namespace? (using x::y, from x import y etc.)

I've been programming in various languages for about 10 years now. And I still haven't figured out when it is a good idea to import something into the global namespace (using x::y in C++, from x ...
6
votes
5answers
3k views

Learn C++ before/at the same time as C#?

I'm currently learning C#, but wondering whether it is beneficial to learn some C++ before/at the same time as in order to understand the concepts a little better? I've got a C++ book and it does seem ...