Код: Выделить всё
anjiowate@Anjis-MacBook-Air weatherApplication % g++ -c ManageLocations.cpp -o ManageLocations.o
ManageLocations.cpp:9:16: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
for (const auto& loc : locations) {
^
ManageLocations.cpp:9:26: warning: range-based for loop is a C++11 extension [-Wc++11-extensions]
for (const auto& loc : locations) {
^
ManageLocations.cpp:16:5: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
auto it = std::find_if(locations.begin(), locations.end(), [&](const Location& loc) { return loc.id == id; });
^
ManageLocations.cpp:16:64: error: expected expression
auto it = std::find_if(locations.begin(), locations.end(), [&](const Location& loc) { return loc.id == id; });
^
ManageLocations.cpp:27:72: error: expected expression
locations.erase(std::remove_if(locations.begin(), locations.end(), [&](const Location& loc) { return loc.id == id; }), locations.end());
^
ManageLocations.cpp:32:16: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
for (const auto& loc : locations) {
^
ManageLocations.cpp:32:26: warning: range-based for loop is a C++11 extension [-Wc++11-extensions]
for (const auto& loc : locations) {
^
ManageLocations.cpp:41:5: warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]
auto it = std::find_if(locations.begin(), locations.end(), [&](const Location& loc) { return loc.id == id; });
^
ManageLocations.cpp:41:64: error: expected expression
auto it = std::find_if(locations.begin(), locations.end(), [&](const Location& loc) { return loc.id == id; });
6 warnings and 3 errors generated.
anjiowate@Anjis-MacBook-Air weatherApplication %
Код: Выделить всё
#ifndef LOCATIONMANAGER_H
#define LOCATIONMANAGER_H
#include
#include
#include
#include
class Location {
public:
std::string id;
std::string name;
double latitude;
double longitude;
bool favorite;
Location(const std::string& id, const std::string& name, double latitude, double longitude, bool favorite = false)
: id(id), name(name), latitude(latitude), longitude(longitude), favorite(favorite) {}
};
class LocationManager {
public:
void addLocation(const std::string& id, const std::string& name, double latitude, double longitude);
void displayLocations();
void modifyLocation(const std::string& id, const std::string& newName, double newLatitude, double newLongitude);
void removeLocation(const std::string& id);
void searchLocation(const std::string& query);
void setFavorite(const std::string& id, bool isFavorite);
void showLocation();
private:
std::vector locations;
};
#endif // LOCATION_MANAGER_H
Код: Выделить всё
#ifndef WEATHERAPP_H
#define WEATHERAPP_H
#include "ManageLocations.h"
#include "weatherForecast.h"
#include "HistoricalWeather.h"
#include "AirQuality.h"
#include "SettingsFetcher.h"
#include
#include
#include
#include
#include
class WeatherApp {
public:
void displayMainMenu();
void run();
};
#endif
edit:: Мне удалось исправить эту ошибку
но теперь я получаю это как ошибку
anjiowate @Anjis-MacBook-Air WeatherApplication % g++ -std=c++11 ManageLocations.cpp -o ManageLocations.o
Неопределенные символы для архитектуры x86_64:
"_main", ссылка из:
ld: символы не найдены для архитектуры x86_64
clang: ошибка: команда компоновщика завершилась неудачно с кодом завершения 1 (используйте -v, чтобы увидеть вызов)
anjiowate@Anjis-MacBook-Air WeatherApplication % g++ -std=c++11 ManageLocations.cpp -o ManageLocations.o
Неопределенные символы для архитектуры x86_64:
"_main", ссылка на:
ld: символ(ы) ) не найдено для архитектуры x86_64
clang: error: команда компоновщика завершилась неудачно с кодом завершения 1 (используйте -v, чтобы увидеть вызов)
anjiowate@Anjis-MacBook-Air WeatherApplication %
Подробнее здесь: https://stackoverflow.com/questions/784 ... -extension
Мобильная версия