Skip to main content

All Questions

2 votes
1 answer
131 views

What's the difference between Radio r = Radio("PSR", 100.8) and Radio("PSR", 100.8)? [duplicate]

I'm new to C++ and trying to understand something. I have this code in my main.cpp: Radio r = Radio("PSR", 100.8); or that code: Radio r("PSR", 100.8); Both seem to work and ...
Sten Göring's user avatar
2 votes
4 answers
1k views

why is assigning values to int pointers different to that from char pointers?

int *p=123; char *s="hi"; i tried searching this question on google but didn't get the exact answer.So, the question is why does the compiler throw error when we assign numbers in the place ...
ARYAN RAJ's user avatar
1 vote
0 answers
46 views

Detailed Initialization Procedure class variable initializer

I saw many confusing answers about the following point : Next, execute either the class variable initializers and static initializers of the class, or the field initializers of the interface, in ...
Mohammad Karmi's user avatar
1 vote
1 answer
2k views

error: request for member '..' in '..' , which is of non-class type [duplicate]

I use an STL priority_queue and give a custom comparator class whose constructor takes in the pointer to the vector that stores the priorities, thus - #include <iostream> #include <queue>...
ameya.dubey's user avatar
4 votes
4 answers
659 views

Why C allows uninitialized local variables?

Looking into languages such as Java & C# use of uninitialized local variable is compile time error. Then why C & C++ allows uninitialized local variables? What is the reason that these ...
Destructor's user avatar
  • 14.4k
77 votes
2 answers
13k views

What are the differences between C-like, constructor, and uniform initialization?

To the best of my knowledge, there are three ways to initialize a variable in C++. int x = 0; // C-like initialization int x (0); // Constructor initialization int x {0}; // Uniform ...
dayuloli's user avatar
  • 17k
3 votes
1 answer
249 views

Why can't I access a member of this class? [duplicate]

I have the following three class definitions: class String { public: String() {} String(const char *) {} }; class ClassA { public: ClassA(const String &) {} }; ...
Nathan Osman's user avatar
  • 73.1k