python (12.9k questions)
javascript (9.2k questions)
reactjs (4.7k questions)
java (4.2k questions)
java (4.2k questions)
c# (3.5k questions)
c# (3.5k questions)
html (3.3k questions)
Can a copy constructor have a non-const lvalue parameter?
class Complex{
int x,y;
public:
void setdata(int x,int y)
{
this->x=x;this->y=y;
}
Complex add(Complex &c)
{
Complex temp;
temp....
Waqar Ahmed
Votes: 0
Answers: 2
Class with no destructor returns copy of object but when I add a destructor it returns the same object
I was playing around with classes in C++, specifically implementing a private constructor with a static "create" function that returns the object.
// main.cpp
#include <iostream>
clas...
mdf
Votes: 0
Answers: 1
define or delete copy ctor in a helper class/struct that uses neither?
I have the following helper utility class defined in a header:
Util.h
struct Timer
{
std::chrono::time_point< std::chrono::steady_clock > start { std::chrono::steady_clock::now( ) };
std...
digito_evo
Votes: 0
Answers: 0
Problems freeing memory in a copy constructor
I have this parent class
class Monster
{
char* nume;
double hp;
float* dmgAbilitati;
int nrAbilitati;
}
with this copy constructor
Monster(const Monster& src)
{
if (n...
bko00
Votes: 0
Answers: 1