Questions tagged [c++]

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

Filter by
Sorted by
Tagged with
-3
votes
1answer
321 views

I loved developing a 2D game(C++ SDL), but i am not good at maths/physics [closed]

I developed 2 games in C++ using SDL. Without using any wrappers. I literally loved and enjoyed every part of the journey. Complex algorithms, how 2D works, rendering, audio, input etc. But i am not ...
-3
votes
2answers
394 views

Is it a bad practice to include stdlib header file from a header file corresponding to the source file that needs that stdlib header?

If a file foo.cpp already includes foo.h, and foo.cpp requires some types from (for example, string.h), which is better, to include string.h in foo.cpp, or in foo.h ? For example, Guideline#9 in this ...
-3
votes
1answer
150 views

Which is the best pattern or solution for this problem?

Given the following class: class S { ... private: void Action1(); void Action2(); . . . void ActionN(); } The Action functions are related, which are called in ...
-3
votes
2answers
3k views

Proper way to implement a “dynamic array of non-default-constructible objects”

As many other questions and answers already stated, there is no syntax in C++ which allows you to declare and fill a dynamic-sized array with non-default constructible objects. Obj* array = new Obj[...
-3
votes
1answer
202 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 ...
-3
votes
1answer
165 views

Is my algorithm for determining whether a ipv4 is public or private correct? [closed]

I have just created a function which checks whether a ipv4 is public or not. I have not heavily tested it yet since it is kind of practically impossible to do so (because I do not know where to start)....
-3
votes
1answer
199 views

Why do many “popular” C++ libraries have a small number of stars on Github? [closed]

For example a CSV parsing library looks to be the most popular CSV parsing library, yet it only has 301 stars. C++ is one of the most popular languages yet C++ libraries on github do not look to be ...
-3
votes
1answer
147 views

Data structures or coding styles in C++ for avoiding long elseif chain when parsing?

Lately I have created some small parsers of data. My initial code structure // more cases here ... else if(!strcmp(X,"somekey")){ // Parse according to "somekey" behavior. } // ...
-3
votes
1answer
492 views

How to make code runnable on open source code editors like Ace Editor?

For my computer science uni project I'm required to build a web application with an integrated code editor. I believe I can just integrate open source editors like Ace Editor. However, I feel ...
-3
votes
1answer
265 views

QElapsedTimer hasExpired() - Is it one msec off?

Here is a a part of the documentation of Qt's QElapsedTimer: bool QElapsedTimer::hasExpired(qint64 timeout) const Returns true if this QElapsedTimer has already expired by timeout milliseconds (...
-3
votes
1answer
52 views

In C++, does it make sens to have library project be composed of other libraries?

I'm working on a C++ project which is currently divided into "sub modules" / "components". Each of these are compiled into a separate library (components are usually 10-20 files). The libraries are ...
-3
votes
1answer
198 views

What is the best way to make a collection of functions available to a whole program in c++?

I am currently working on a voxel (Minecraft-like) engine in C++. Almost all of the code (ie. world generation, rendering, user input) needs to access data about the block types. To accomplish this, I ...
-3
votes
1answer
622 views

Physics/Game Engine in C++ for mobile app [closed]

First post so be gentle. I am a junior seeking a Comp Sci major and was looking into making a mobile game. I wanted to use this for my thesis project next year, and possibly a way to pay back college ...
-4
votes
2answers
126 views

Why is C++ not updated as frequently as Java? [closed]

Java was last revised in 2020, while C++ had it's update back in 2017
-4
votes
4answers
621 views

What are good ways to parse a large amount of input for a C++ application [closed]

For small command line applications I can get away with simple command line input. ./test input.png output.png But for larger applications that requires a lot of input, simply using command line ...
-4
votes
2answers
1k views

recommend a design pattern for a C++ application that takes some data, processes it, and returns results

So I am new to design patterns and C++11, but I have been studying both quite a bit. I am working on developing a C++ application to process some data, and I was hoping that someone with more ...
-4
votes
1answer
502 views

TIOBE Index: why c++ is in 3rd place and C is having more land in the last year?

Searching for c++ ranking on the TIOBE index, I was stumped to see that C is in front of C++, and from 2017, C took a leap. Could someone explain why?
-4
votes
2answers
236 views

Can derived class be singleton? [closed]

I need to have some common functionality while the derived class needs to have singleton behavior. For example: class A { //common file functions } class B : public A { //Needs to be singleton . ...
-4
votes
1answer
107 views

What things should you consider when porting software from python to c++?

Suppose you have written a prototype for an application in python, now you want to rewrite it in c++ for speed reasons and to make a real software out of it. What are things to consider before ...
-4
votes
1answer
77 views

What is best design pattern to simplfy class with a lot of options to create it?

I have a base class [for example]: class base { private: std::string name; public: virtual void set_name(const std::string& name) = 0; virtual std::string get_name() const = 0; }; ...
-4
votes
1answer
132 views

Is it really good idea to disable warning of C or Cpp? [duplicate]

When we are working on a big project of C or CPP, we are getting some warning. Therefore, we try to remove that warning because when we see compiler warnings that they make us feel dirty. When we ...
-4
votes
1answer
243 views

Inheritance of Constructors from parent into child class [closed]

Is the Default Constructor of Super or Parent class Can be Inherited into Child class ?
-4
votes
1answer
70 views

Using only the Cache not the DRAM in a Program (USB to Ethernet) [closed]

I am reading some data from USB, do some packet processing and then send the result to the Ethernet port. The USB ports are connected to an onboard USB Hub where it communicates with the ...
-4
votes
0answers
36 views

How to find the least number of digit that need to be changed for the number to become “HARD” [closed]

The number is "Hard" if digits on i-position and j-position (j>i) are equal to C, and then digit on k-position is also equal to C.(examples of hard numbers : 233441 and 335. Now out of ...
-4
votes
1answer
943 views

Exiting Recursive Function C++ [closed]

In the following function IsDoubleString(),if res is true then it shouldn't call IsDoubleString(), I debugged the code but I am unable to understand that once it hit the line returns res; why does the ...
-5
votes
3answers
203 views

Why solve a problem with a class and not a function?

I am a new to in programming, especially to C++. At first I learned how I make functions (it was amazing). But now that I've learned about classes (and objects) I am so confused... when I should use ...
-5
votes
2answers
173 views

What is the proper way to unspecify an integer's value in C++? [closed]

// Default initialization int i; // i has an unspecified value return i; // Probably 0, but Unreliable i = 5; // i has a specified value i = int();// This will give it a specified value, 0 i = ...
-6
votes
1answer
645 views

What's the best algorithm to assign unique ID/serial numbers to a group of identical objects?

to make this question easier to visualize, let's call this the "chicken mesh problem". Suppose you have a rooster and a number (suppose it is 30) of baby chickens. Goal: Allow the rooster to ...
-7
votes
3answers
2k views

Char array - why do we need +1 byte for sentinel value?

Can anyone explain why do we need +1 byte for sentinel value? As we know that 1 char = 1 byte so if we declare an array such as char a[50] why I can't store 50 chars instead of 49?
-7
votes
1answer
95 views

method and class overloading (good programming practice or ridiculousness) [closed]

I have yet to hear an answer from anyone as to why overloading of any type is a sound programing practice. Calling the same function name with an almost infinite number of variations on the surface ...
-8
votes
1answer
1k views

Why code in C instead of C++ [closed]

Why code in C? Isn't C++ basically C but with better features? Why do people still use C? Would it be easier to make a game with C or C++?
-8
votes
1answer
353 views

Importance of storage in c++ [closed]

I want to know that whether storage is an issue with respect to current hardware and software market when we talk about the large size of C++ programs?? Because in certain conditions we have to choose ...
-9
votes
1answer
782 views

Why runtime ploymorphism is required? [closed]

Why runtime ploymorphism is required ? give a real example that "why it came into existence when we have compile time polymorphism??" As mainting the runtime polymorphism requires lot of overhead of ...
-10
votes
1answer
9k views

Using delete this to free memory in class

Whenever we are writing destructors in C++ (though this concept could apply in other languages) could we just not write delete this; and it would delete whatever data is inside of the class? Is this ...

1
46 47 48 49
50