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

learn more… | top users | synonyms

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
605 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 ...
33
votes
2answers
6k 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
433 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
380 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
1k 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
146 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
182 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
603 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 ...
0
votes
4answers
2k views

How should I go about developing some basic C/C++ knowledge so that I can grok the concepts written in some Classic software programming books? [closed]

I know Java and JavaScript pretty well. I have never really worked on C/C++. But at this stage of my career I feel that the fact that I do not have adequate knowledge on C/C++ syntax(especially ...
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
788 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
689 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
998 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 ...
0
votes
7answers
5k views

How to find siblings of a tree?

On my interview for an internship, I was asked following question: On a whiteboard write the simplest algorithm with use of recursion which would take a root of a so called binary tree (so called ...
2
votes
1answer
245 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 ...
2
votes
4answers
536 views

How to provide a ubiquitous object without including it in every parameter list

I'm writing a small C++ class, Block, to transform serialized data into a memory structure, and supply the structured data to callers through several accessor methods. I've tried to keep its scope ...
1
vote
2answers
299 views

Event based logging. Is it a good idea and is it ok to pass a handle to a “logged” object?

Hi I have fairly complex program that is doing computations in a quite large loop. I want to log some basic statistic about the run to be able to analyze its performance over time and vs loop number. ...
8
votes
3answers
705 views

C++ Web Development: Wanting a minimalist start [closed]

I'm currently working on a Computer Science degree, and I want to build my own Web Server library. The problem? Every search I've done on interacting with web sites points to "Use this library that ...
0
votes
1answer
432 views

Comparing performance of different C++ self-made tree data structures

I have two tree data-structures that I made in C++ , and they give a response for range queries/point queries in that program. I am using Ubuntu. I need help in understanding the way to compare the ...
0
votes
1answer
496 views

Is there a proper way to allow access to private list by reference?

I'm trying to provide a by-reference getter to a list of objects in a class. My setup looks something roughly like this: class c_Container { public: c_Item* Get(int uid); private: c_Item ...
1
vote
1answer
261 views

Improving the efficiency of containers with dynamically allocated objects

This is not strictly related to C++ but its type system serves to illustrate the problem well. Assume: We have a generic template Container<T> (such as a std::vector<T>) which stores an ...
5
votes
6answers
2k views

Stroustrup and the C++ complexity admission [closed]

I heard from a friend that Bjarne Stroustroup admitted that he doesn't know entirely the C++ programming language due to its vast complexity Is it true and there's some referrable sources or is it ...
1
vote
1answer
867 views

register variable in C and C++

I know the concept of register variable and it's use cases but there are few questions in my mind based on what I have tried. I cannot access the address of a register variable in C though I can do ...
-1
votes
5answers
890 views

New to Programming/objective c [closed]

I've recently started to work on some iPhone apps, starting from a base where I had essentially no programming experience (I studied Maths & had very few programming modules) I worked my way ...
19
votes
3answers
2k views

Must I think about compiled machine code when I write my code?

For example I've got following code: auto z = [](int x) -> int { if (x > 0) { switch (x) { case 2: return 5; case 3: return 6; default: return 1; ...
1
vote
4answers
2k views

Help with learning the C++ Qt Framework [closed]

I've been a longtime PHP web developer. But now I've reached the limits and web doesn't fascinate me anymore. I am interested in learning cross-platform development. I have learned Java for almost a ...
2
votes
5answers
638 views

Why is TDD not working here?

I want to write a class A that has a method calculate(<params>). That method should calculate a value using database data. So I wrote a class Test_A for unit testing (TDD). The database access ...
0
votes
1answer
383 views

Understanding how memory contents map into a struct [closed]

I am not able to understand how bytes in memory are being mapped into a struct. My machine is a little-endian x86_64. The code was compiled with gcc 4.7.0 from the Win64 mingw32-64 distribution for ...
0
votes
2answers
654 views

When to decide to introduce interfaces (pure abstract base classes) in C++?

Assume that you are developing a functionality and are 90% sure that the implementation class will stay alone. If I was in this position in Java I would probably not use the interface right now to ...
3
votes
3answers
1k views

C++ log every function and parameter values

I want to log every function call and parameter value in my C++ app. Is there a generic approach for this task ? (3rd part library, VAR_ARGS etc.)
3
votes
1answer
396 views

Are C or C++ The Only Viable Languages for a GC

Background I have just finished writing a compiler for a functional language compiling to the JVM as a learning project. However, since I'm just doing this to learn, I thought it might be interesting ...
0
votes
1answer
124 views

Share Mulitple Classes as one dll or a lib with Mulitple Projects

Currently I have some shared class files(.cpp and .h) which I include them in around 20 Projects. Currently I have to include them in all of the projects. So if I get some business requirments and I ...
0
votes
3answers
191 views

which style of member-access is preferable [duplicate]

the purpose of oop using classes is to encapsulate members from the outer space. i always read that accessing members should be done by methods. for example: template<typename T> class foo_1 { ...
4
votes
4answers
7k views

Putting semicolons after while and if statements in C++

How come in C++ when you put: while (expression); the while loop doesn't run no matter if the expression is true or not. However if you put: if (expression); the statement runs no matter if ...
10
votes
8answers
2k views

Should we persist with an employee still writing bad code after many years? [closed]

I am putting this question to C++ programmers because: a) Only a C++ programmer can judge the technical merits of the examples; b) Only a programmer will have a feel for the temperament of another ...
4
votes
2answers
357 views

Writing Large Portions Of Code Then Debugging?

Lately I have been writing a game engine, and I have been writing a lot of "foundation stuff" (standard interfaces, modules, a message system ect.), but I have noticed a pattern, a lot of the stuff is ...
26
votes
3answers
2k views

Except garbage collector, what else makes Java a non real time programming language

Except the garbage collector, what are some other features in Java that make it unsuitable for real time programming? On the net, whenever Java vs C++ is discussed with regards to real time ...
31
votes
3answers
27k views

Why is Python written in C and not in C++? [closed]

In Python's tutorial one can read that Python's original implementation is in C; On the other hand, the Python implementation, written in C, (...) I'm very curious why was Python written in C ...
17
votes
7answers
5k views

Learning C++ properly (not C with classes) [duplicate]

The typical reason I hear to why people bash C++ is that they don't actually know C++, they just know "C with classes", which apparently is different. I am just beginning to learn C++, however, I want ...
7
votes
5answers
553 views

Is it a good idea to read compiler source code? [closed]

I'm a junior in college majoring in Computer Science. Apart from writing lots of code, I want to start reading source code written by others to improve my coding skills and learn better/different ways ...