我正在尝试将一维数组分配给我的默认构造函数,但我不断收到此错误消息。有没有办法为同一个类创建两个默认构造函数,一个没有参数,一个有参数?
标题
#include <iostream>
#include <string>
using namespace std;
#ifndef SUBWAY_H
#define SUBWAY_H
class Track
{
public:
//Default Constructor
Track(); //error here
//Destructor
~Track();
//Member variables
char node_1;
char node_2;
bool visited;
};
class Station
{
public:
//Default Constructor
Station();
//Destructor
~Station();
//Member variables
char station_name;
int track_starting_ID;
int track_size;
};
class SubwaySystem
{
public:
//Default Constructor
SubwaySystem();
//Destructor
~SubwaySystem();
//Member variables
Track my_track[34];
Station my_station[12];
int count_routes;
};
#endif
cpp
#include "subway.h"
SubwaySystem::SubwaySystem()
{
my_track[0] = Track('a', 'b'); //error here
...
}