In main(), I am making an array myAppointments, and realize to make it work I would need to create a default constructor in Appointments.h, but when I do I get this error:
no matching function for call to 'Time::Time()'
Appointment(){
Here is Main:
/*
* Homework 4 -- UPDATE as needed
*/
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include "Appointment.h"
using namespace std;
void callPrint (Time &TimeOrApptObject) { TimeOrApptObject.print(); }
int main(){
int month, day, year, hour, minute,howLong;
Appointment myAppointments[19];
ifstream HW4DataFileHandle;
HW4DataFileHandle.open("Lab6Data.txt");
while (!HW4DataFileHandle.eof( )) {
for (int i = 1; i < 20; i++) {
HW4DataFileHandle>>month;
HW4DataFileHandle>>day;
HW4DataFileHandle>>year;
HW4DataFileHandle>>hour;
HW4DataFileHandle>>minute;
HW4DataFileHandle>>howLong;
myAppointments[i] = Appointment( month, day, year, hour, minute, howLong);
}
cout <<"enter a month" <<endl;
cin >> month;
cout <<"enter a day" <<endl;
cin >> day;
cout <<"enter a year"<<endl;
cin >> year;
Date myDate( month, day, year);
cout <<"Appointments for" << month <<"/" << day <<"/" << year <<":"<< endl;
for (int i = 0; i <13; i++){
if ( myAppointments[i]==Date myDate )
{
Time thisTime = myAppointments[i];
thisDate.print();
cout << endl;
}
}
}
And here are the header files:
Date.H
// Date.h -- Class Date UPDATE as needed
#ifndef DATE_H
#define DATE_H
class Date {
private:
int month;
int day;
int year;
public:
Date(int m, int d, int y) : month(m), day(d), year(y)
{
}
friend bool friendTorCompare2Dates (const Date&,const Date& );
};
bool friendTorCompare2Dates (const Date& Right, const Date& Left)
{
if (Right.month == Left.month && Right.day == Left.day )
return true;
else
return false;
}
#endif
Time.H
//Time.h -- Class Time UPDATE as needed
using namespace std;
#include<iostream>
#ifndef TIME_H
#define TIME_H
class Time {
private :
int hour; int minute;
public:
Time(int h, int m) : hour(h)
{
}
virtual void print() {
cout << hour << " " << minute <<" " ;
}
};
#endif
Appointment.h
// Appointment.h -- Class Appointment UPDATE as needed
//
using namespace std;
#include "Time.h"
#include "Date.h"
#ifndef APPOINTMENT_H
#define APPOINTMENT_H
class Appointment: public Date, public Time {
private:
int howLong;
public:
Appointment(int month, int day, int year, int hour, int minute, int howLong) :
Date(month, day, year), Time(hour, minute), howLong(howLong)
{
}
Appointment(){
month;
day;
year;
hour;
minute;
howLong;
}
};
#endif
What do I need to change in order to have my default constructor in Appointment work? If you notice any thing else, or have any other questions in regards to my question, please let me know. I would appreciate it if you would include an example in your answer.
This line:
Appointment myAppointments[19];
will call the default constructor of Appointment for each element.
Your default constructor doesn't explicitly call a constructor of Time, so the default constructor of Time will be called, which doesn't exist. Same with Date.
You can reinstate the default constructor like this:
class Time {
// ...
public:
Time() = default;
};
To get reasonable default behavior, you should provide default initial values for the members of your class, e.g.
class Time {
private :
int hour = 0;
int minute = 0;
public:
// ...
};
When you declare the array Appointment myAppointments[19];, the default constructor for Appointment is used immediately for all 19 elements. However, Date and Time do not have default constructors defined, but Appointment's default constructor will try to call them both implicitly, hence the error you are seeing since they don't exist.
So, you have 4 different ways to fix this:
make Appointment's default constructor call Date's and Time's non-default constructors explicitly (just like your other Appointment constructor does), passing in default values to them:
Appointment() :
Date(0, 0, 0), Time(0, 0), howLong(0)
{
}
give Date and Time their own default constructors, eg:
class Date {
private:
int month;
int day;
int year;
public:
Date() : month(0), day(0), year(0)
{
}
Date(int m, int d, int y) : month(m), day(d), year(y)
{
}
...
};
class Time {
private :
int hour;
int minute;
public:
Time() : hour(0), minute(0)
{
}
Time(int h, int m) : hour(h), minute(m)
{
}
...
};
Alternatively:
class Date {
private:
int month;
int day;
int year;
public:
Date(int m = 0, int d = 0, int y = 0) : month(m), day(d), year(y)
{
}
...
};
class Time {
private :
int hour;
int minute;
public:
Time(int h = 0, int m = 0) : hour(h), minute(m)
{
}
...
};
Alternatively (C++11 and later only):
class Date {
private:
int month = 0;
int day = 0;
int year = 0;
public:
Date() = default;
// or:
// Date() : Date(0, 0, 0) {}
Date(int m, int d, int y) : month(m), day(d), year(y)
{
}
...
};
class Time {
private :
int hour = 0;
int minute = 0;
public:
Time() = default;
// or:
// Time() : Time(0, 0) {}
Time(int h, int m) : hour(h), minute(m)
{
}
...
};
construct the array elements explicitly using placement-new so you can use Appointment's non-default constructor on them, eg:
typedef unsigned char AppointmentBuf[sizeof(Appointment)];
// better:
// #include <type_traits>
// using AppointmentBuf = std::aligned_storage<sizeof(Appointment), alignof(Appointment)>::type;
int main(){
AppointmentBuf myAppointments[19];
...
for (int i = 0; i < 19; i++) {
...
new (&myAppointments[i]) Appointment(month, day, year, hour, minute, howLong);
}
...
for (int i = 0; i < 19; i++) {
Appointment &appt = reinterpret_cast<Appointment&>(myAppointments[i]);
// use appt as needed...
}
...
// cleanup
for (int i = 0; i < 19; i++) {
reinterpret_cast<Appointment&>(myAppointments[i]).~Appointment();
}
return 0;
}
Change the array to hold Appointment* pointers, and then construct the array elements dynamically via new using Appointment's non-default constructor, eg:
int main(){
Appointment* myAppointments[19] = {};
...
for (int i = 0; i < 19; i++) {
...
myAppointments[i] = new Appointment(month, day, year, hour, minute, howLong);
}
...
for (int i = 0; i < 19; i++) {
// use myAppointments[i] as needed...
}
...
// cleanup
for (int i = 0; i < 19; i++) {
delete myAppointments[i];
}
return 0;
}
Alternatively (C++11 or later only):
#include <memory>
int main(){
std::unique_ptr<Appointment> myAppointments[19];
...
for (int i = 0; i < 19; i++) {
...
myAppointments[i] = std::make_unique<Appointment>(month, day, year, hour, minute, howLong);
}
...
for (int i = 0; i < 19; i++) {
// use myAppointments[i] as needed...
}
...
// no manual cleanup needed
return 0;
}
Related
Is it possible to call cpp file into main, without using header?
I tried in VS 2019 something like that:
main.cpp
#include<iostream>
int main()
{
Date birthday{3,2,2};
birthday.getDay();
std::cout << "User, input the day";
int u_day = 0;
std::cin >> u_day;
birthday.print(u_day);
return 0;
}
another.cpp
#include<iostream>
class Date
{
private:
int m_year;
int m_month;
int m_day;
public:
Date() = default;
Date(int year, int month, int day) {
setDate(year, month, day);
}
void setDate(int year, int month, int day) {
m_year = year;
m_month = month;
m_day = day;
}
int getYear() { return m_year; }
int getMonth() { return m_month; }
int getDay() { return m_day; }
void print(int day) {
m_day = day;
std::cout << m_day;
}
};
Now there are a lot of C2056 errors,
When I add Date::Date birthday{3,2,2}; in the main.cpp
I get E0276, E0065, C2653,C2065,C2146
I have some trouble figuring out a few things. Basically I have 2 classes, and whenever I create the objects, it works completely fine. However when I try to push_back to a vector in main() function, it return 0 0 0 (B default values), and if I try to make a void function, which would do this, it gives back segmentation fault. Any ideas?
class Date
{
public:
Date(int day=0, int month=0, int year=0) : _day(day), _month(month),_year(year) {}
int get_day() { return _day; }
int get_month() { return _month; }
int get_year() { return _year; }
void writestuff() { std::cout << _day << "/" << _month << "/" << _year<< std::endl; }
~Date(){}
private:
int _day;
int _month;
int _year;
};
class Adatok
{
public:
Adatok(std::string name, std::string path, Date date ): _name(name), _path(path), _date(date) {}
void writestuff()
{
std::cout<<_name<<" "<<_path<<" ";
_date.writestuff();
std::cout<<std::endl;
}
Adatok(const Adatok& other){}
Adatok operator= (const Adatok& other){}
~Adatok(){}
private:
std::string _name;
std::string _path;
Date _date;
};
void database(std::string& temp, std::vector<Adatok> my_vec); // this would be the segmentation fault code, it's not implemented anymore
int main(int argc, char **argv)
{
std::vector<Adatok> my_vec;
std::string temp;
boost::filesystem::ifstream input_file("input");
while (getline(input_file, temp))
{
//---------------------------------don't mind theese------------------------------------------------------------------
temp += ',';
std::string name = temp.substr(temp.find_first_of('"'),temp.find_first_of(','));
temp.erase(0, name.length() + 1);
std::string path = temp.substr(temp.find_first_of('"'),temp.find_first_of(','));
temp.erase(0, path.length() + 1);
std::string numbers(temp.substr(temp.find_first_of('"') + 1,temp.find_first_of('-')));
int year, month, day;
year = std::atoi(numbers.c_str());
temp.erase(0, temp.find_first_of('-') + 1);
numbers = temp.substr(0, temp.find_first_of('-'));
month = std::atoi(numbers.c_str());
temp.erase(0, temp.find_first_of('-') + 1);
numbers = temp.substr(0, temp.find_first_of(' '));
day = std::atoi(numbers.c_str());
//Date obj(day, month, year);
//Adatok elem(name, path, obj);
//---------------------------------------don't mind theese-----------------------------------------------------------------
my_vec.push_back(Adatok(name,path,Date(day,month,year))); //probably fails
}
for(std::vector<Adatok>::iterator it{my_vec.begin()};it !=my_vec.end();it++)
it -> writestuff();
return 0;
}
"however when i try to push_back to a vector in MAIN function, it
return 0 0 0 (B default values)"
This is because of not initializing the member variables of B class. This should be done when you push_back the a new A object to the std::vector like follows:
vecA.push_back(A("name", "path", B(15, 04, 2018)));
If your doubt is how to to use push_back is, above will certainly clarified it.
Update: I have set the copy constructor and copy assignment operator to default and it worked. Live action: https://www.ideone.com/TlmAm2
#include <iostream>
#include <string>
#include <vector>
class Date
{
public:
Date(int day = 0, int month = 0, int year = 0)
: _day(day), _month(month),_year(year) {}
~Date(){}
int get_day() { return _day; }
int get_month() { return _month; }
int get_year() { return _year; }
void writestuff()
{
std::cout << _day << "/" << _month << "/" << _year<< std::endl;
}
private:
int _day;
int _month;
int _year;
};
class Adatok
{
public:
Adatok(std::string name, std::string path, Date date )
: _name(name), _path(path), _date(date) {}
~Adatok(){}
void writestuff()
{
std::cout<<_name<<" "<<_path<<" ";
_date.writestuff();
std::cout<<std::endl;
}
//change in copy constructor and copy assignment operator
Adatok(const Adatok& other) = default;
Adatok& operator= (const Adatok& other) = default;
private:
std::string _name;
std::string _path;
Date _date;
};
void database(std::string temp, std::vector<Adatok> my_vec)
{
for(auto& it: my_vec)
it.writestuff();
}
int main(int argc, char **argv)
{
std::vector<Adatok> my_vec;
int year = 2018, month = 04, day = 15;
std::string name = "name1", path = "path1";
my_vec.push_back(Adatok(name,path,Date(day,month,year)));
database("something", my_vec);
return 0;
}
I have a problem in returning a struct from a method declared in a class. The struct i is composed by 3 integers: day, month and year.
I set these three values using a method in the class.
struct dmy{
int day, month, year;
};
dmy c;
Then I have a method to return the full struct
dmy Date::getS(){
return c;
}
But I get lots of errors in compiling. What should I do?
I've also read Is it safe to return a struct in C or C++? but I haven't solved my issue.
The program is composed from main.cpp, Difference.h and Date.h
Errors in Date.h :
[Error] 'dmy' does not name a type
Main
using namespace std;
#include <iostream>
#include "Date.h"
int main(int argc, char** argv) {
Date date1;
Date date2;
cout<<"Insert first date\n";
date1.setAll();
return 0;
}
Date.h
class Date{
public:
Date(){
}
~Date(){
}
void setAll();
struct dmy{
int day, month, year;
};
dmy c;
dmy getS();
private:
void setDay();
void setMonth();
void setYear();
};
void Date::setAll(){
setDay();
setMonth();
setYear();
}
void Date::setDay(){
do{
cout<<"Type day: ";
cin>>c.day;
}while(0<c.day<31);
}
void Date::setMonth(){
//didn't right the checking again
cout<<"Type month: ";
cin>>c.month;
}
void Date::setYear(){
cout<<"Type year: ";
cin>>c.year;
}
dmy Date::getS(){
return c;
}
NOTE: The struct was called 'i'
Example
#include <cstdio>
#include <cstdlib>
struct DateInfo {
int day;
int month;
int year;
};
class Date {
public:
Date(const int day, const int month, const int year) : m_info( { day, month, year } )
{
//n/a
}
DateInfo get_info( void ) const
{
return m_info;
}
private:
DateInfo m_info;
};
int main( int, char** )
{
Date date( 29, 02, 1984 );
DateInfo info = date.get_info( );
printf( "%i\n", info.year );
return EXIT_SUCCESS;
}
Build
g++ -std=c++11 -o date date.cpp
instead of
dmy Date::getS(){
return c;
}
write
Date::dmy Date::getS(){
return c;
}
since "dmy" is not in the global namespace.
Try this:
class C1
{
public:
struct S1
{
int a,b,c;
};
S1 f1() { S1 s; return s; }
};
void main()
{
C1 c;
C1::S1 s;
s=c.f1();
}
C1 - class
C1::S1 - struct inside class C1
C1::f1 - function returning C1::S1
I doubt that your source code is compiled in the C style other that C++ style. You could try to change the file extension to ".cpp" instead of ".c" and then gcc will do it's job in C++ style.
I have two classes (appointment, schedule), and a driver (main).
main.cpp:
#include <iostream>
#include "schedule.h"
#include "appointment.h"
using namespace std;
int main()
{
schedule mySch2("hello");
appointment myAppt(100002,"appointment",10,1,2013);
myAppt.printS(cout,2);
mySch2.addtoSchedule(myAppt);
system("PAUSE");
return EXIT_SUCCESS;
}
schedule.h
#ifndef SCHEDULE_H
#define SCHEDULE_H
#include<iostream>
#include "appointment.h"
using namespace::std;
const int SCH_ENTRIES = 10;
class schedule
{
public:
schedule(void);
schedule(const char *p);
bool addtoSchedule(const appointment &);
private:
char title[40];
int count;
appointment appointmentArray[SCH_ENTRIES];
};
#endif
schedule.cpp
#include "schedule.h"
#include "appointment.h"
#include <iostream>
using namespace::std;
schedule::schedule(void)
{
}
schedule::schedule(const char *p)
{
strcpy(title, p);
count = 0;
cout << title << endl;
cout << count << endl;
cout << "----" << endl;
}
bool schedule::addtoSchedule(const appointment & myAppt)
{
cout << appointmentArray[0].getDay();
return false;
}
appointment.h (I did not write this, this was provided) - not super important for this question
#ifndef APPOINTMENT_H
#define APPOINTMENT_H
#include <fstream>
#include <cstring>
using std::ostream;
// The Designer decides upon the following data and actions (i.e. Functions)
// and places the class in the file appointment.h
class appointment
{
public:
appointment(void); // default constructor
appointment(long, const char [],int d, int m, int y); // 5 argument constructor
appointment(const appointment &); // copy constructor
void keyBoardInput(void); // Assume no blanks in the desc
long getSource(void) const; // return source
void setSource(long); // change source
void setMonth(int);
void setDay(int);
void setYear(int);
int getMonth(void) const;
int getDay(void) const;
int getYear(void) const;
const char *getDescription(void) const; // return the address of the description
void changeDescription(const char *) ; // change an existing description
void copyTo(appointment &) const; // copy invoking instance to parameter
void incrementDate (void); // advance the date by ONE day
// You can assume 30 days in each month
void printS(ostream &, int dateFormat) const; // print all fields
// dateFormat == 1 month/day/year
// dateFormat == 2 day/month/year
~appointment(); // destructor - indicate the address
// of the variable that is leaving
private:
void setDescription(const char *); // used to allocated memory
// data
long source; // id of the person scheduling the appointment
char * desc; // description of the appointment - Dynamic Data
int day; // day, month, and year when the appointment
int month; // will happen
int year;
};
#endif
appointment.cpp (I did not write this, this was provided) - not super important for this question
#include "appointment.h"
#include <iostream>
using std::cin;
using std::cout;
appointment::appointment()
{
day = 0;
cout << "default appt\n";
}
appointment::appointment(long lSource, const char cDescription[], int d, int m, int y)
{
source = lSource;
day = d;
month = m;
year = y;
setDescription(cDescription);
}
appointment::appointment(const appointment & aToCopy)
{
source = aToCopy.getSource();
day = aToCopy.getDay();
month = aToCopy.getMonth();
year = aToCopy.getYear();
setDescription(aToCopy.getDescription());
}
void appointment::setDescription(const char * cSource)
{
if (desc != NULL) free (desc);
if (cSource == NULL)
return;
desc = (char *)malloc (strlen (cSource) + 1);
strcpy(desc, cSource);
}
long appointment::getSource(void) const
{
return source;
}
void appointment::setSource(long lSource)
{
source = lSource;
}
void appointment::setMonth(int iMonth)
{
month = iMonth;
}
void appointment::setDay(int iDay)
{
day = iDay;
}
void appointment::setYear(int iYear)
{
year = iYear;
}
int appointment::getMonth(void) const
{
return month;
}
int appointment::getDay(void) const
{
return day;
}
int appointment::getYear(void) const
{
return year;
}
//return the address of the description
const char * appointment::getDescription(void) const
{
return desc;
}
//change an existing description
void appointment::changeDescription(const char * cDescription)
{
setDescription(cDescription);
}
void appointment::copyTo(appointment &p) const
{
p.source = source;
p.day = day;
p.month = month;
p.year = year;
p.setDescription(desc);
}
void appointment::incrementDate(void)
{
int days;
switch (month)
{
case 1: // Jan: 31 Days
case 3: // Mar: 31 Days
case 5: // May: 31 Days
case 7: // Jul: 31 Days
case 10: // Oct: 31 Days
case 12: // Dec: 31 Days
days = 31;
break;
case 4: // Apr: 30
case 6: // Jun: 30
case 8: // Aug: 30
case 9: // Sep: 30
case 11: // Nov: 30
days = 30;
break;
case 2: // Feb: 28/29 Days (Depends on year modulus 4 a modulus 100).
days = !(year % 4) || !(year % 100) ? 29 : 28;
break;
}
day++;
if (day > days)
{
month++;
day = 1;
if (month > 12)
{
month = 1;
year++;
}
}
}
void appointment::printS(ostream &out, int dateFormat) const
{
if (dateFormat == 1)
{
out << month << "/" << day << "/" << year << "\n";
}
else if (dateFormat == 2)
{
out << day << "/" << month << "/" << year << "\n";
}
else
out << "Unsupported dateFormat parameter specified (should be 1 or 2).";
}
appointment::~appointment()
{
if (desc != NULL)
{
free (desc);
desc = NULL;
}
}
void appointment::keyBoardInput()
{
char temp[1024];
cout << "Please type the description: ";
cin.getline (temp, sizeof(temp) - 1, '\n');
cout << std::endl;
setDescription(temp);
}
My error occurs when the main driver calls mySch2.addtoSchedule(myAppt);
If I uncomment out the line inside of schedule appointmentArray[0].getDay() then everything runs and works fine with no segmentation error. As soon as that line gets uncommented, it throws the error during runtime (after a crash and I go into the debugger and step through the program).
You never initialize desc to nullptr for class appointment before invoking setDescription. This happens in both constructors. Learn to use an initializer list:
appointment::appointment()
: source(), desc(), day(), month(), year()
{
cout << "default appt\n";
}
appointment::appointment(long lSource, const char cDescription[], int d, int m, int y)
: source(lSource), desc(), day(d), month(m), year(y)
{
setDescription(cDescription);
}
appointment::appointment(const appointment & aToCopy)
: source(aToCopy.getSource())
, desc()
, day(aToCopy.getDay())
, month(aToCopy.getMonth())
, year(aToCopy.getYear())
{
setDescription(aToCopy.getDescription());
}
Why did it fault?
Without initialization the value in desc is indeterminate and therefore undefined behavior to dereference, and certainly so to pass to free.
void appointment::setDescription(const char * cSource)
{
if (desc != NULL) free (desc); // desc contains non-null garbage.
if (cSource == NULL)
return;
desc = (char *)malloc (strlen (cSource) + 1);
strcpy(desc, cSource);
}
That said, I would strongly encourage using a std::string instead. It would make the copy-consructor for this class completely disappear, and the default constructor trivial.
Comments about using malloc() in a C++ program reserved, as that opinion is all-but beat to death already on this forum (and I agree with te prevailing opinion).
I have a class constructor which accepts string, struct, enum and int as parameters. Apart from this I also have a default constructor.
Whenever I call my class functions using the object name that's created using the parametered constructor, I'm getting some error saying member is of non-class type. But I don't get any error if I use the default constructors object name.
Car obj(string bini, struct Date dini, enum Status state, int id);
obj.getBrand(); //doesn't work. getting non-class type error
Car obj1; //constructor without parameters
obj1.getBrand(); //works fine
here's the more detailed code.
//main.cpp
struct Date
{
int year = 0;
int month = 0;
int day = 0;
};
enum Status{ OK, SOLD, DEFECT };
int main()
{
string bini = "";
int id = 0;
Car obj(string bini, struct Date dini, enum Status state, int id);
obj.getBrand(); //doesn't work. getting non-class type error
// Car obj1; //constructor without parameters
//obj1.getBrand(); //works fine
}
//Car.h
class Car
{
public:
struct TDate
{
int year;
int month;
int day;
};
enum TStatus{ OK, SOLD, DEFECT };
void getID();
void getPrice();
void getBrand();
TStatus getStatus();
TDate getManufactureDate();
void setPrice(float price);
void setStatus(TStatus state);
void sellCar();
Car();
Car(string bini, struct TDate dini, enum TStatus sini, int id);
protected:
private:
TStatus state[100];
string brand[100];
float priceEuro[100];
int carId[100], bc = 0, pc = 0, dc = 0, sc = 0;
TDate manufatureDate[100];
};
//Car.cpp
Car::Car(string bini, struct TDate dini, enum TStatus sini, int id)
{
for(int i = 0; i < 100; i++)
{
brand[i] = {bini};
manufatureDate[i].day = dini.day;
manufatureDate[i].month = dini.month;
manufatureDate[i].year = dini.year;
state[i] = sini;
carId[i] = id;
}
}
void Car::getBrand()
{
cout << "Enter the Brand of the Car : " << endl;
cin >> brand[bc];
carId[bc] = bc;
bc++;
}
I don't get the mistake I'm doing here. Help would be appreciated. Thanks
Car obj(string bini, struct Date dini, enum Status state, int id);
That's a function declaration. Leave out the types of the variables you pass.
Car obj(bini, dini, state, id);
Finally I found what the mistake is. The struct and enum of Car.cpp should be defined globally. And then its variable declaration should be done in main.cpp as it's done below.
//main.cpp
int main()
{
string bini = "";
int id = 0;
TDate dini; //previously i was using separate temporary struct and enum
dini.day = 0; //inside main, that was not necessary. Now since the class Car's
dini.month = 0; //struct and enum are global i can use them here to declare variables
dini.year = 0; //for enum, i directly passed the value OK thru constructor
int id = 0;
Car obj1(bini, dini, OK, id);
obj1.getBrand(); //no error now
}
//Car.h
struct TDate //**global definition**
{
int year;
int month;
int day;
};
enum TStatus{ OK, SOLD, DEFECT };
class Car
{
public:
void getBrand();
Car();
Car(string bini, TDate dini,TStatus sini, int id);
private:
TStatus state[100];
string brand[100];
float priceEuro[100];
int carId[100], bc = 0, pc = 0, dc = 0, sc = 0;
TDate manufatureDate[100];
};
//Car.cpp
Car::Car(string bini, TDate dini, TStatus sini, int id)
{
for(int i = 0; i < 100; i++)
{
brand[i] = {bini};
manufatureDate[i].day = dini.day;
manufatureDate[i].month = dini.month;
manufatureDate[i].year = dini.year;
state[i] = sini;
carId[i] = id;
}
}
void Car::getBrand()
{
cout << "Enter the Brand of the Car : " << endl;
cin >> brand[bc];
carId[bc] = bc;
bc++;
}
Thanks.