call to constructor with brackets after () [closed]
up vote
-6
down vote
favorite
I need to declare a constructor in C++ so I can call it like this:
Drawing("van")[
Point(3, 4),
Circle(5, 3, 2),
Point(5, 8),
Cube(1, 1, 4)
];
Do I have to overload () and to achieve this? And if yes how because I cannot understand how to achieve this!
I want this interface to work as is, I need to overload only and how?
c++ operator-overloading
closed as unclear what you're asking by hellow, MrTux, VTT, Werner Henze, Swordfish Nov 5 at 7:26
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
|
show 4 more comments
up vote
-6
down vote
favorite
I need to declare a constructor in C++ so I can call it like this:
Drawing("van")[
Point(3, 4),
Circle(5, 3, 2),
Point(5, 8),
Cube(1, 1, 4)
];
Do I have to overload () and to achieve this? And if yes how because I cannot understand how to achieve this!
I want this interface to work as is, I need to overload only and how?
c++ operator-overloading
closed as unclear what you're asking by hellow, MrTux, VTT, Werner Henze, Swordfish Nov 5 at 7:26
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
1
You're not going to get that syntax without being intrusive to these shape types. It also won't be sustainable if the comma operator is deprecated or removed for use as a subscript, which has come up as idea for allowing more natural multidimensional overloading. (Although if that does happen, this could be reworked to fit it.)
– chris
Nov 5 at 7:11
1
And even if you do go the (possible) length to make that expression well formed, what's the point? What is the expression supposed to accomplish?
– StoryTeller
Nov 5 at 7:12
1
What you're proposing doesn't read well as an interface. A more natural interface would beDrawingto have anAddShape()member to be called four times.
– acraig5075
Nov 5 at 7:14
3
Not sure about the heavy downvoting. Are we not allowed to ask intriguing questions? Yes, it is possible to do this, although would be some work. One problem is the arity of, but you could exploit the sequencing properties of the expression separator operator,.
– Bathsheba
Nov 5 at 7:50
1
DONT. DO. THAT. ideone.com/FFQqHq
– Swordfish
Nov 5 at 8:53
|
show 4 more comments
up vote
-6
down vote
favorite
up vote
-6
down vote
favorite
I need to declare a constructor in C++ so I can call it like this:
Drawing("van")[
Point(3, 4),
Circle(5, 3, 2),
Point(5, 8),
Cube(1, 1, 4)
];
Do I have to overload () and to achieve this? And if yes how because I cannot understand how to achieve this!
I want this interface to work as is, I need to overload only and how?
c++ operator-overloading
I need to declare a constructor in C++ so I can call it like this:
Drawing("van")[
Point(3, 4),
Circle(5, 3, 2),
Point(5, 8),
Cube(1, 1, 4)
];
Do I have to overload () and to achieve this? And if yes how because I cannot understand how to achieve this!
I want this interface to work as is, I need to overload only and how?
c++ operator-overloading
c++ operator-overloading
edited Nov 6 at 16:16
jv42
7,83733258
7,83733258
asked Nov 5 at 7:08
Nikos K
155
155
closed as unclear what you're asking by hellow, MrTux, VTT, Werner Henze, Swordfish Nov 5 at 7:26
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
closed as unclear what you're asking by hellow, MrTux, VTT, Werner Henze, Swordfish Nov 5 at 7:26
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
1
You're not going to get that syntax without being intrusive to these shape types. It also won't be sustainable if the comma operator is deprecated or removed for use as a subscript, which has come up as idea for allowing more natural multidimensional overloading. (Although if that does happen, this could be reworked to fit it.)
– chris
Nov 5 at 7:11
1
And even if you do go the (possible) length to make that expression well formed, what's the point? What is the expression supposed to accomplish?
– StoryTeller
Nov 5 at 7:12
1
What you're proposing doesn't read well as an interface. A more natural interface would beDrawingto have anAddShape()member to be called four times.
– acraig5075
Nov 5 at 7:14
3
Not sure about the heavy downvoting. Are we not allowed to ask intriguing questions? Yes, it is possible to do this, although would be some work. One problem is the arity of, but you could exploit the sequencing properties of the expression separator operator,.
– Bathsheba
Nov 5 at 7:50
1
DONT. DO. THAT. ideone.com/FFQqHq
– Swordfish
Nov 5 at 8:53
|
show 4 more comments
1
You're not going to get that syntax without being intrusive to these shape types. It also won't be sustainable if the comma operator is deprecated or removed for use as a subscript, which has come up as idea for allowing more natural multidimensional overloading. (Although if that does happen, this could be reworked to fit it.)
– chris
Nov 5 at 7:11
1
And even if you do go the (possible) length to make that expression well formed, what's the point? What is the expression supposed to accomplish?
– StoryTeller
Nov 5 at 7:12
1
What you're proposing doesn't read well as an interface. A more natural interface would beDrawingto have anAddShape()member to be called four times.
– acraig5075
Nov 5 at 7:14
3
Not sure about the heavy downvoting. Are we not allowed to ask intriguing questions? Yes, it is possible to do this, although would be some work. One problem is the arity of, but you could exploit the sequencing properties of the expression separator operator,.
– Bathsheba
Nov 5 at 7:50
1
DONT. DO. THAT. ideone.com/FFQqHq
– Swordfish
Nov 5 at 8:53
1
1
You're not going to get that syntax without being intrusive to these shape types. It also won't be sustainable if the comma operator is deprecated or removed for use as a subscript, which has come up as idea for allowing more natural multidimensional overloading. (Although if that does happen, this could be reworked to fit it.)
– chris
Nov 5 at 7:11
You're not going to get that syntax without being intrusive to these shape types. It also won't be sustainable if the comma operator is deprecated or removed for use as a subscript, which has come up as idea for allowing more natural multidimensional overloading. (Although if that does happen, this could be reworked to fit it.)
– chris
Nov 5 at 7:11
1
1
And even if you do go the (possible) length to make that expression well formed, what's the point? What is the expression supposed to accomplish?
– StoryTeller
Nov 5 at 7:12
And even if you do go the (possible) length to make that expression well formed, what's the point? What is the expression supposed to accomplish?
– StoryTeller
Nov 5 at 7:12
1
1
What you're proposing doesn't read well as an interface. A more natural interface would be
Drawing to have an AddShape() member to be called four times.– acraig5075
Nov 5 at 7:14
What you're proposing doesn't read well as an interface. A more natural interface would be
Drawing to have an AddShape() member to be called four times.– acraig5075
Nov 5 at 7:14
3
3
Not sure about the heavy downvoting. Are we not allowed to ask intriguing questions? Yes, it is possible to do this, although would be some work. One problem is the arity of
, but you could exploit the sequencing properties of the expression separator operator ,.– Bathsheba
Nov 5 at 7:50
Not sure about the heavy downvoting. Are we not allowed to ask intriguing questions? Yes, it is possible to do this, although would be some work. One problem is the arity of
, but you could exploit the sequencing properties of the expression separator operator ,.– Bathsheba
Nov 5 at 7:50
1
1
DONT. DO. THAT. ideone.com/FFQqHq
– Swordfish
Nov 5 at 8:53
DONT. DO. THAT. ideone.com/FFQqHq
– Swordfish
Nov 5 at 8:53
|
show 4 more comments
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
1
You're not going to get that syntax without being intrusive to these shape types. It also won't be sustainable if the comma operator is deprecated or removed for use as a subscript, which has come up as idea for allowing more natural multidimensional overloading. (Although if that does happen, this could be reworked to fit it.)
– chris
Nov 5 at 7:11
1
And even if you do go the (possible) length to make that expression well formed, what's the point? What is the expression supposed to accomplish?
– StoryTeller
Nov 5 at 7:12
1
What you're proposing doesn't read well as an interface. A more natural interface would be
Drawingto have anAddShape()member to be called four times.– acraig5075
Nov 5 at 7:14
3
Not sure about the heavy downvoting. Are we not allowed to ask intriguing questions? Yes, it is possible to do this, although would be some work. One problem is the arity of
, but you could exploit the sequencing properties of the expression separator operator,.– Bathsheba
Nov 5 at 7:50
1
DONT. DO. THAT. ideone.com/FFQqHq
– Swordfish
Nov 5 at 8:53