Код: Выделить всё
g++ -std=c++11 -c subject.cpp -o subject.o
In file included from subject.cpp:1:
In file included from ./subject.hpp:1:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/iostream:41:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/ios:221:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__locale:18:
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/memory:848:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/allocator.h:165:28: error: no matching constructor for initialization of 'Subject'
::new ((void*)__p) _Up(_VSTD::forward(__args)...);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__memory/allocator_traits.h:290:13: note: in instantiation of function template specialization 'std::allocator::construct' requested here
__a.construct(__p, _VSTD::forward(__args)...);
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/vector:808:21: note: in instantiation of function template specialization 'std::allocator_traits::construct' requested here
__alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__tx.__pos_),
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/vector:1597:9: note: in instantiation of function template specialization 'std::vector::__construct_one_at_end' requested here
__construct_one_at_end(_VSTD::forward(__args)...);
^
subject.cpp:50:22: note: in instantiation of function template specialization 'std::vector::emplace_back' requested here
subjects.emplace_back(s_id, s_name,s_credit,s_prerequisite,majors);
^
subject.cpp:3:10: note: candidate constructor not viable: no known conversion from 'std::vector' to 'std::string' (aka 'basic_string') for 5th argument
Subject::Subject(string subject_id_,string subject_name_,string credit_,string prerequisite_,string qualified_majors_id_)
^
./subject.hpp:9:7: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 5 were provided
class Subject{
^
./subject.hpp:9:7: note: candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 5 were provided
1 error generated.
make: *** [subject.o] Error 1
это другие файлы на случай, если с ними возникнут проблемы:
cpp :
Код: Выделить всё
#include "subject.hpp"
Subject::Subject(string subject_id_,string subject_name_,string credit_,string prerequisite_,string qualified_majors_id_)
{
subject_id=subject_id_;
subject_name=subject_name_;
credit=credit_;
prerequisite=prerequisite_;
qualified_majors_id=qualified_majors_id_;
}
string Subject::get_subject_id(){return subject_id;}
string Subject::get_subject_name(){return subject_name;}
string Subject::get_credit(){return credit;}
string Subject::get_prerequisite(){return prerequisite;}
string Subject::get_qualified_majors_id(){return qualified_majors_id;}
vector readSubjectFromCSV(string &filename)
{
vector subjects;
ifstream file(filename);
if (!file.is_open())
{
cerr
Подробнее здесь: [url]https://stackoverflow.com/questions/78519382/i-get-this-error-regarding-the-constructor-when-i-try-to-compile-with-g-and-i[/url]
Мобильная версия