most-vexing-parse Questions
2
I was reading an SO post where one user made the following comment:
Also note that ArrTest<int> ar(); uses most vexing parse.
But another user said the opposite:
ArrTest<int> ar(); i...
Rustcolored asked 20/4, 2022 at 9:51
6
Solved
On Wikipedia I found this:
A a( A() );
[This] could be disambiguated either as
a variable definition of class [A], taking an anonymous instance of class [A] or
a function declaration for a...
Repast asked 29/12, 2012 at 0:44
7
Solved
i just run into the problem
error: request for member ‘show’ in ‘myWindow’, which is of non-class type ‘MainGUIWindow()’
when trying to compile a simple qt-application:
#include <QApplicati...
Neff asked 25/2, 2011 at 11:15
1
Solved
In the following code
#include <map>
#include <string>
struct P2d {
double x, y;
P2d(double x, double y) : x(x), y(y) {}
};
double bar() {
std::map<std::string, int> m;
//P2...
Animism asked 22/6, 2020 at 15:39
3
Solved
I'm certainly missing something, but I do not understand why this compiles (with both g++ & clang++):
struct A
{
};
struct B
{
};
int main()
{
A a(B);
}
First of all, B is a type... not a ...
Whaling asked 3/12, 2019 at 17:40
1
Solved
I have a variable of type long long that represents a time point in nanoseconds.
I'm trying to wrap it using std::chrono::time_point yet the compiler (VS 2017) is giving me troubles.
here is a co...
Strother asked 16/6, 2019 at 12:6
2
Solved
This code causes compilation error (most vexing parse)
#include <iostream>
class A {
int a;
public:
A(int x) :a(x) {}
};
class B {
public:
B(const A& obj) { std::cout << "B\n"...
Pantsuit asked 21/2, 2019 at 15:46
3
I can do this:
#include <iostream>
int counter;
int main()
{
struct Boo
{
Boo(int num)
{
++counter;
if (rand() % num < 7) Boo(8);
}
};
Boo(8);
return 0;
}
This will compil...
Galoot asked 16/12, 2018 at 22:9
2
Solved
Having read about the most vexing parse, I experimented a bit and found this program. There are two very similar lines. One of them yields warnings in both g++7 and clang++-3.9, another does not.
...
Noel asked 21/2, 2018 at 18:28
1
Solved
C++11 allows in-class initialization:
struct Foo{
std::vector<std::string> v{3}; // vector of 3 empty strings
};
If we wanted to initialize in-class a vector of ints, we would get s...
Tithe asked 10/2, 2018 at 16:33
1
Solved
After watching Louis Brandy talk at CppCon 2017 I was shocked to discover that this code actually compiles:
#include <string>
int main() {
std::string(foo);
return 0;
}
And for...
Dierdre asked 29/12, 2017 at 21:18
2
Solved
While looking at some C++03 code, I found an instance of the most vexing parse that confused me:
#include <sstream>
#include <string>
int main(int, char** argv)
{
std::stringstream s...
Bandy asked 12/12, 2017 at 15:19
9
Solved
Is there any good reason that an empty set of round brackets (parentheses) isn't valid for calling the default constructor in C++?
MyObject object; // ok - default ctor
MyObject object(blah); // o...
Noted asked 7/10, 2008 at 20:13
1
Solved
I have the class
class A
{
public:
class Key
{
Key() {}
Key(Key const &) {}
};
A(Key key, int a = 5) {}
};
The constructor for Key is private, so no one should be able to construct an...
Jepum asked 29/9, 2017 at 14:34
2
Solved
I've been having difficulties understanding move constructors in C++. I have made a simple class with a default constructor, copy constructor, move constructor and destructor. Also, I have defined ...
Octodecimo asked 2/6, 2017 at 14:15
1
Solved
class foo {
public:
bool operator () (int & i) {
return true;
}
};
int main() {
foo(WhyDoesThisCompile);
return 0;
}
When passing WhyDoesThisCompile (without spaces) to the funct...
Vickers asked 15/4, 2017 at 20:15
3
Solved
I'm putting together a C++-based assignment for a class I'm teaching. I have a function I'm exporting to students that I'd like them to call at various points in their program so that, during gradi...
Jaconet asked 19/1, 2017 at 18:35
2
Is the Most Vexing Parse rooted in the ambiguity about whether or not to use void as the parameter of a function declaration that takes no arguments?
As an example, the following code compiles wit...
Hartwell asked 17/1, 2017 at 18:37
2
Solved
Today at work I came across a behavior in C++ which I don't understand. I have produced the following example code to illustrate my problem:
#include <string>
#include <iostream>
clas...
Dowery asked 23/11, 2016 at 14:54
3
Solved
I'm faced with a compile error that I don't even know how to describe! It completely baffles me.
The situation:
Code tries to create an object on the stack with an rvalue std::string that is init...
Graeae asked 17/8, 2016 at 6:9
2
Solved
I saw a code here at Cpp Quiz [Question #38]
#include <iostream>
struct Foo
{
Foo(int d) : x(d) {}
int x;
};
int main()
{
double x = 3.14;
Foo f( int(x) );
std::cout <<...
Luik asked 15/8, 2016 at 8:1
2
Solved
I'm just curious to know why this small piece of code compiles correctly (and without warnings) in Visual Studio. Maybe the result is the same with GCC and Clang, but unfortunately I can't test the...
Quatrain asked 22/12, 2015 at 13:32
1
Solved
I was going through this article
and there is a statement in item 3 saying
// C++98
rectangle w( origin(), extents() ); // oops, vexing parse
how is the above a most vexing parse. If I did som...
Roper asked 22/7, 2015 at 21:47
1
Solved
I am a fairly experienced .net developer but new to Arduino and C/C++ and I am trying to create my first library which is a simple driver for a 7 segment led display. I have many obtuse compiler er...
Nook asked 19/7, 2015 at 0:18
2
Solved
For example a declaration such as that:
int (x) = 0;
Or even that:
int (((x))) = 0;
I stumbled upon this because in my code I happened to have a fragment similar to the following one:
struct...
Scorpaenoid asked 16/4, 2015 at 13:5
1 Next >
© 2022 - 2024 — McMap. All rights reserved.