State Error C2535 dflt_ctor_closure(void)': member function already defined or declared
I have a C++ project and I get this error. I know the error is because I have 2 functions with the same name but they have different arguments. How to fix this?
BaseE::BaseE(double x=0.0, double y=0.0)
{
......
}
BaseE::BaseE(double x=0.0):
{
....
}
c++ visual-studio visual-c++
add a comment |
I have a C++ project and I get this error. I know the error is because I have 2 functions with the same name but they have different arguments. How to fix this?
BaseE::BaseE(double x=0.0, double y=0.0)
{
......
}
BaseE::BaseE(double x=0.0):
{
....
}
c++ visual-studio visual-c++
With almost 100 reputation and you don't create an MCVE? :/ :/ :/
– gsamaras
Nov 26 '18 at 13:04
Why do you need two functions?
– StoryTeller
Nov 26 '18 at 13:05
@gsamaras what do you mean? StoryTeller I call them based on how many arguments I need
– manuel_k
Nov 26 '18 at 13:07
In what circumstance would you need to call the second one? Why won't calling the first withy=0.0
do?
– StoryTeller
Nov 26 '18 at 13:08
add a comment |
I have a C++ project and I get this error. I know the error is because I have 2 functions with the same name but they have different arguments. How to fix this?
BaseE::BaseE(double x=0.0, double y=0.0)
{
......
}
BaseE::BaseE(double x=0.0):
{
....
}
c++ visual-studio visual-c++
I have a C++ project and I get this error. I know the error is because I have 2 functions with the same name but they have different arguments. How to fix this?
BaseE::BaseE(double x=0.0, double y=0.0)
{
......
}
BaseE::BaseE(double x=0.0):
{
....
}
c++ visual-studio visual-c++
c++ visual-studio visual-c++
edited Nov 26 '18 at 13:04
gsamaras
52.3k25107193
52.3k25107193
asked Nov 26 '18 at 13:01
manuel_kmanuel_k
941217
941217
With almost 100 reputation and you don't create an MCVE? :/ :/ :/
– gsamaras
Nov 26 '18 at 13:04
Why do you need two functions?
– StoryTeller
Nov 26 '18 at 13:05
@gsamaras what do you mean? StoryTeller I call them based on how many arguments I need
– manuel_k
Nov 26 '18 at 13:07
In what circumstance would you need to call the second one? Why won't calling the first withy=0.0
do?
– StoryTeller
Nov 26 '18 at 13:08
add a comment |
With almost 100 reputation and you don't create an MCVE? :/ :/ :/
– gsamaras
Nov 26 '18 at 13:04
Why do you need two functions?
– StoryTeller
Nov 26 '18 at 13:05
@gsamaras what do you mean? StoryTeller I call them based on how many arguments I need
– manuel_k
Nov 26 '18 at 13:07
In what circumstance would you need to call the second one? Why won't calling the first withy=0.0
do?
– StoryTeller
Nov 26 '18 at 13:08
With almost 100 reputation and you don't create an MCVE? :/ :/ :/
– gsamaras
Nov 26 '18 at 13:04
With almost 100 reputation and you don't create an MCVE? :/ :/ :/
– gsamaras
Nov 26 '18 at 13:04
Why do you need two functions?
– StoryTeller
Nov 26 '18 at 13:05
Why do you need two functions?
– StoryTeller
Nov 26 '18 at 13:05
@gsamaras what do you mean? StoryTeller I call them based on how many arguments I need
– manuel_k
Nov 26 '18 at 13:07
@gsamaras what do you mean? StoryTeller I call them based on how many arguments I need
– manuel_k
Nov 26 '18 at 13:07
In what circumstance would you need to call the second one? Why won't calling the first with
y=0.0
do?– StoryTeller
Nov 26 '18 at 13:08
In what circumstance would you need to call the second one? Why won't calling the first with
y=0.0
do?– StoryTeller
Nov 26 '18 at 13:08
add a comment |
2 Answers
2
active
oldest
votes
The default constructor for a class is a constructor that takes no arguments. It's special: the compiler will generate one if you don't define one (oversimplified). Here, the class has two default constructors, because each one of those can be called with no arguments. That's why it's complaining. Too many default arguments.
add a comment |
The way you currently have it, when the compiler encounters a call to BaseE(), it can't tell if you meant to call BaseE(0.0, 0.0) (the first constructor, with default arguments), or BaseE(0.0) (the 2nd constructor with default arguments). This is the ambiguity the compiler is complaining about;
You should remove the default arguments from (at least) one of the constructor implementations.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53481712%2fstate-error-c2535-dflt-ctor-closurevoid-member-function-already-defined-or-d%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
The default constructor for a class is a constructor that takes no arguments. It's special: the compiler will generate one if you don't define one (oversimplified). Here, the class has two default constructors, because each one of those can be called with no arguments. That's why it's complaining. Too many default arguments.
add a comment |
The default constructor for a class is a constructor that takes no arguments. It's special: the compiler will generate one if you don't define one (oversimplified). Here, the class has two default constructors, because each one of those can be called with no arguments. That's why it's complaining. Too many default arguments.
add a comment |
The default constructor for a class is a constructor that takes no arguments. It's special: the compiler will generate one if you don't define one (oversimplified). Here, the class has two default constructors, because each one of those can be called with no arguments. That's why it's complaining. Too many default arguments.
The default constructor for a class is a constructor that takes no arguments. It's special: the compiler will generate one if you don't define one (oversimplified). Here, the class has two default constructors, because each one of those can be called with no arguments. That's why it's complaining. Too many default arguments.
answered Nov 26 '18 at 13:06
Pete BeckerPete Becker
58.8k442122
58.8k442122
add a comment |
add a comment |
The way you currently have it, when the compiler encounters a call to BaseE(), it can't tell if you meant to call BaseE(0.0, 0.0) (the first constructor, with default arguments), or BaseE(0.0) (the 2nd constructor with default arguments). This is the ambiguity the compiler is complaining about;
You should remove the default arguments from (at least) one of the constructor implementations.
add a comment |
The way you currently have it, when the compiler encounters a call to BaseE(), it can't tell if you meant to call BaseE(0.0, 0.0) (the first constructor, with default arguments), or BaseE(0.0) (the 2nd constructor with default arguments). This is the ambiguity the compiler is complaining about;
You should remove the default arguments from (at least) one of the constructor implementations.
add a comment |
The way you currently have it, when the compiler encounters a call to BaseE(), it can't tell if you meant to call BaseE(0.0, 0.0) (the first constructor, with default arguments), or BaseE(0.0) (the 2nd constructor with default arguments). This is the ambiguity the compiler is complaining about;
You should remove the default arguments from (at least) one of the constructor implementations.
The way you currently have it, when the compiler encounters a call to BaseE(), it can't tell if you meant to call BaseE(0.0, 0.0) (the first constructor, with default arguments), or BaseE(0.0) (the 2nd constructor with default arguments). This is the ambiguity the compiler is complaining about;
You should remove the default arguments from (at least) one of the constructor implementations.
answered Nov 26 '18 at 14:03
DanDan
276
276
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53481712%2fstate-error-c2535-dflt-ctor-closurevoid-member-function-already-defined-or-d%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
With almost 100 reputation and you don't create an MCVE? :/ :/ :/
– gsamaras
Nov 26 '18 at 13:04
Why do you need two functions?
– StoryTeller
Nov 26 '18 at 13:05
@gsamaras what do you mean? StoryTeller I call them based on how many arguments I need
– manuel_k
Nov 26 '18 at 13:07
In what circumstance would you need to call the second one? Why won't calling the first with
y=0.0
do?– StoryTeller
Nov 26 '18 at 13:08