Форум программистов, компьютерный форум, киберфорум
С++ для начинающих
Войти
Регистрация
Восстановить пароль
Карта форума Темы раздела Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 4.91/11: Рейтинг темы: голосов - 11, средняя оценка - 4.91
9 / 9 / 1
Регистрация: 02.08.2010
Сообщений: 270
1

ошибка компилятор ругается...

01.12.2010, 22:21. Показов 1931. Ответов 8
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
C++
1
LDay::LDay(DayOfWeek today,unsigned short int Lessons,time LessonTime,string s1, string s2="TEST",string s3="",string s4="",string s5="",string s6="",string s7="",string s8="",string s9="",string s10="")
(здесь используются аргументы по умолчанию для s2-s10).

ругается:

D:\c++\time\main.cpp|71|error: default argument given for parameter 5 of 'LDay::LDay(DayOfWeek, short unsigned int, time, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string)'|
D:\c++\time\main.cpp|55|error: after previous specification in 'LDay::LDay(DayOfWeek, short unsigned int, time, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string)'|
D:\c++\time\main.cpp|71|error: default argument given for parameter 6 of 'LDay::LDay(DayOfWeek, short unsigned int, time, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string)'|
D:\c++\time\main.cpp|55|error: after previous specification in 'LDay::LDay(DayOfWeek, short unsigned int, time, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string)'|
D:\c++\time\main.cpp|71|error: default argument given for parameter 7 of 'LDay::LDay(DayOfWeek, short unsigned int, time, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string)'|
D:\c++\time\main.cpp|55|error: after previous specification in 'LDay::LDay(DayOfWeek, short unsigned int, time, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string)'|
D:\c++\time\main.cpp|71|error: default argument given for parameter 8 of 'LDay::LDay(DayOfWeek, short unsigned int, time, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string)'|
D:\c++\time\main.cpp|55|error: after previous specification in 'LDay::LDay(DayOfWeek, short unsigned int, time, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string)'|
D:\c++\time\main.cpp|71|error: default argument given for parameter 9 of 'LDay::LDay(DayOfWeek, short unsigned int, time, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string)'|
D:\c++\time\main.cpp|55|error: after previous specification in 'LDay::LDay(DayOfWeek, short unsigned int, time, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string)'|
D:\c++\time\main.cpp|71|error: default argument given for parameter 10 of 'LDay::LDay(DayOfWeek, short unsigned int, time, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string)'|
D:\c++\time\main.cpp|55|error: after previous specification in 'LDay::LDay(DayOfWeek, short unsigned int, time, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string)'|
D:\c++\time\main.cpp|71|error: default argument given for parameter 11 of 'LDay::LDay(DayOfWeek, short unsigned int, time, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string)'|
D:\c++\time\main.cpp|55|error: after previous specification in 'LDay::LDay(DayOfWeek, short unsigned int, time, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string)'|
D:\c++\time\main.cpp|71|error: default argument given for parameter 12 of 'LDay::LDay(DayOfWeek, short unsigned int, time, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string)'|
D:\c++\time\main.cpp|55|error: after previous specification in 'LDay::LDay(DayOfWeek, short unsigned int, time, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string)'|
D:\c++\time\main.cpp|71|error: default argument given for parameter 13 of 'LDay::LDay(DayOfWeek, short unsigned int, time, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string)'|
D:\c++\time\main.cpp|55|error: after previous specification in 'LDay::LDay(DayOfWeek, short unsigned int, time, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string)'|
||=== Build finished: 18 errors, 0 warnings ===|


когда где-нибудь убираю аргумент по умолчанию ругатся на этот агумент перестаёт.
p.s. я довольно недавно в программировании возможно вопрос тупой простите уж за "ламерство".....
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
01.12.2010, 22:21
Ответы с готовыми решениями:

Ошибка в конструкторе с параметром. Компилятор не ругается, но при запуске программы возникает ошибка
Я знаю точно, что ошибка в конструкторе с параметром. Компилятор не ругается, но при запуске моей...

Ошибка в коде, не могу исправить, ругается компилятор
//#include "stdafx.h" #include <iostream> #include <cstdlib> #include <fstream> using namespace...

swap function. Ругается компилятор. В чем ошибка? На помощь !
#include <iostream> #include <stdio.h> template <typename PData> void Swap(int PData&...

ругается компилятор:
#include <stdio.h> #include <iostream> #include <process.h> #include <conio.h> #include...

8
В астрале
Эксперт С++
8049 / 4806 / 655
Регистрация: 24.06.2010
Сообщений: 10,562
01.12.2010, 22:24 2
А если так?) Да и кстати.. Пространство имен-то подключено?

C++
1
LDay::LDay(DayOfWeek today,unsigned short int Lessons,time LessonTime,string s1, string s2=string("TEST"),string s3=string(),string s4=string(),string s5=string(),string s6=string(),string s7=string(),string s8=string(),string s9=string(),string s10=string())
0
9 / 9 / 1
Регистрация: 02.08.2010
Сообщений: 270
01.12.2010, 22:27  [ТС] 3
Цитата Сообщение от ForEveR Посмотреть сообщение
А если так?) Да и кстати.. Пространство имен-то подключено?

C++
1
LDay::LDay(DayOfWeek today,unsigned short int Lessons,time LessonTime,string s1, string s2=string("TEST"),string s3=string(),string s4=string(),string s5=string(),string s6=string(),string s7=string(),string s8=string(),string s9=string(),string s10=string())
std-да, подключено
нет,говорит то же самое
0
В астрале
Эксперт С++
8049 / 4806 / 655
Регистрация: 24.06.2010
Сообщений: 10,562
01.12.2010, 23:00 4
polimorf96, А при каком вызове функции он так говорит?
0
9 / 9 / 1
Регистрация: 02.08.2010
Сообщений: 270
01.12.2010, 23:08  [ТС] 5
Цитата Сообщение от ForEveR Посмотреть сообщение
polimorf96, А при каком вызове функции он так говорит?
это определение конструктора.
в классе он был только объявлен.
а после определён-LDay::LDay.....
если взглануть на ошибку то кажется что он ругается на прототип(или портотип как правильно я не помню) и на определение.
ну а функции определяются вне каких-либо функций....
0
В астрале
Эксперт С++
8049 / 4806 / 655
Регистрация: 24.06.2010
Сообщений: 10,562
01.12.2010, 23:10 6
polimorf96, При создании объекта с какими параметрами идет ругань? Или же идет без создания? Просто тут телепатов нет...
И да. Аргументы по умолчанию должны быть указаны в прототипе только насколько я помню. Вообщем скиньте код. Будет проще.
0
9 / 9 / 1
Регистрация: 02.08.2010
Сообщений: 270
01.12.2010, 23:14  [ТС] 7
Цитата Сообщение от ForEveR Посмотреть сообщение
polimorf96, При создании объекта с какими параметрами идет ругань? Или же идет без создания? Просто тут телепатов нет...
И да. Аргументы по умолчанию должны быть указаны в прототипе только насколько я помню. Вообщем скиньте код. Будет проще.
Действительно,думаю будет проще....
:
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#include <iostream>
#include <fstream>
#include <conio.h>
using namespace std;
typedef unsigned short int DayOfWeek ;
/////////////////////////////
class time
{
    private:
    int hh,mm;
    public:
    time(int hours=12,int minutes=50)
    {
        hh=hours;mm=minutes;
    }
    int GetMinutes() const
    {
        return mm;
    }
    int GetHours() const
    {
        return hh;
    }
    void SetTime(int hours,int minutes)
    {
        hh=hours;mm=minutes;
    }
    time operator +(time t2)
    {
        time t3;
        t3.SetTime(hh+t2.GetHours(),mm+t2.GetMinutes());
        if((mm+t2.GetMinutes())>=60)
        {
            t3.SetTime(t3.GetHours()+1,0);
        }
        return t3;
    }
    time operator =(time t2)
    {
        hh=t2.hh;
        mm=t2.mm;
        return *this;
    }
};
/////////////////////////////////////
 
class LDay
{
    private:
    DayOfWeek Day;
    unsigned short int NofLessons;
    time FirstLessonTime;
    string LessonsName [10];
    public:
    LDay(DayOfWeek today,unsigned short int Lessons,time LessonTime,string s1, string s2=string(),string s3=string(),string s4=string(),string s5=string(),string s6=string(),string s7=string(),string s8=string(),string s9=string(),string s10=string());
    unsigned short int GetNofLessons() const
    {
        return NofLessons;
    }
    time GetTime()
    {
        return FirstLessonTime;
    }
    string GetLesson(unsigned short int n) const
    {
        return LessonsName[n-1];
    }
};
///////////////////////////////////////////////
////LDay constructor//////////
LDay::LDay(DayOfWeek today,unsigned short int Lessons,time LessonTime,string s1, string s2=string(),string s3=string(),string s4=string(),string s5=string(),string s6=string(),string s7=string(),string s8=string(),string s9=string(),string s10=string())
{
    Day = today;
    NofLessons = Lessons;
    FirstLessonTime = LessonTime;
    ///////создадим расписание дня///////
    LessonsName[0]=s1;
    LessonsName[1]=s2;
    LessonsName[2]=s3;
    LessonsName[3]=s4;
    LessonsName[4]=s5;
    LessonsName[5]=s6;
    LessonsName[6]=s7;
    LessonsName[7]=s8;
    LessonsName[8]=s9;
    LessonsName[9]=s10;
    /////////////////////////////////
}
 
int main()
{
    cout << "Welcome to my programm!" << endl;
    char ch;
    cout << "Create new DAT base?[Y/N]?" << endl;
    ch = getche();
    if(ch == 'Y')
    {
        fstream file;
        cout << "Enter a path:" << endl;
        cout << ">> ";
        char mpath[255]="";
        cin >> mpath;
        cout << endl;
        ///////////////////////////////////////////////////
        file.open(mpath,ios::out|ios::binary|ios::trunc);
        if(!file)
        {
            cerr << "Error to creating file!" << endl;
            return(1);
        }
        ///////////////////////////////////////////////////
        ///создадим стандартное время такое как 12:55,13:30,14:00//
        time NulLesson(12,55);
        time FirstLesson(13,30);
        time Other(14,00);
        time Subbota(10,20);
        ///создадим стандартное время (длительность урока  и т.п//
        time LessonTime(00,45);
        ////////////////////////////////////////////////////
        ///LDay(DayOfWeek,unsigned short int,time,string s1,s2="",s3="",s4="",s5="",s6="",s7="",s8="",s9="",s10=""); это мне чтобы не забыть прототип////
        //создание базы данных начиная с понедельника///
        LDay d1(1,5,Other,"In-yaz","Algebra","Litra","Algebra","Fizra");
        LDay d2(2,7,NulLesson,"Geographia","Russkiy","Himia","In-yaz","Fizra","Muzika","Istoria");
        LDay d3(3,5,FirstLesson,"Biologia","Russky","Fizika","Geometria","Izo");
        LDay d4(4,7,NulLesson,"Himia","Algebra","In-yaz","Informatika","Biologia","Biologia","Obshestvo");
        LDay d5(5,7,NulLesson,"OBG","Russkiy","Literatura","Algebra","Geometria","TRZ/THA","TRZ/THA");
        LDay d6(6,5,Subbota,"Himia","Fiz-ra","Istoria","Fizika","Geographia");
        ////////////////////////////////////////////////////////////
        ////////////Заполняем .DAT файл нашими объектами//////////////
        file.seekg(0);
        file.write(reinterpret_cast<char*>(&d1),sizeof(d1));
        file.write(reinterpret_cast<char*>(&d2),sizeof(d2));
        file.write(reinterpret_cast<char*>(&d3),sizeof(d3));
        file.write(reinterpret_cast<char*>(&d4),sizeof(d4));
        file.write(reinterpret_cast<char*>(&d5),sizeof(d5));
        file.write(reinterpret_cast<char*>(&d6),sizeof(d6));
        file.close();
        cout << ".DAT file creating OK!." << endl;
        ch = 'z';
        cout << "Exit?[Y/N]?";
        ch = getche();
        if (ch=='Y'||ch=='y')
        {return 0}
    }
    return 0;
}
0
В астрале
Эксперт С++
8049 / 4806 / 655
Регистрация: 24.06.2010
Сообщений: 10,562
01.12.2010, 23:17 8
polimorf96, В определении не надо указывать, что параметры по умолчанию. Достаточно в прототипе (объявлении).

и #include <string> неплохо бы

C++
1
2
3
4
LDay::LDay(DayOfWeek today,unsigned short int Lessons,time LessonTime,string s1, string s2,string s3,string s4,string s5,string s6,string s7,string s8,string s9,string s10)
{
   //Code
}
1
9 / 9 / 1
Регистрация: 02.08.2010
Сообщений: 270
01.12.2010, 23:19  [ТС] 9
Цитата Сообщение от ForEveR Посмотреть сообщение
polimorf96, В определении не надо указывать, что параметры по умолчанию. Достаточно в прототипе (объявлении).

и #include <string> неплохо бы

C++
1
2
3
4
LDay::LDay(DayOfWeek today,unsigned short int Lessons,time LessonTime,string s1, string s2,string s3,string s4,string s5,string s6,string s7,string s8,string s9,string s10)
{
   //Code
}
СПАСИБО!
теперь запомню
0
01.12.2010, 23:19
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
01.12.2010, 23:19
Помогаю со студенческими работами здесь

Ругается компилятор
Компилирую программу: // Proba2.cpp: определяет точку входа для консольного приложения. // ...

Компилятор ругается
Условие Создать класс, содержащий сведения о количестве изделий, собранный сборщиками цеха за...

Компилятор не ругается
Компилятор по разному реагирует на 2 указателя на строки (см.комментарии). В связи с этим появился...

Ругается компилятор
Создать класс жидкость, имеющий название (указатель на строку), плотность. Определить конструкторы,...


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
9
Ответ Создать тему
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2024, CyberForum.ru