1
我正在編寫一個程序,該程序可以幫助我瞭解C++中的枚舉數據類型。目前的麻煩是,編譯器不像我使用其他數據類型時那樣嘗試使用新數據類型時喜歡我的枚舉用法。編譯我的trangleShape函數時,出現「重新聲明爲不同類型符號」的錯誤。看看相關的代碼。任何見解都被讚賞!謝謝!枚舉問題:重新聲明爲不同類型的符號
(所有功能都是自己的.cpp文件。)
頭文件
#ifndef HEADER_H_INCLUDED
#define HEADER_H_INCLUDED
#include <iostream>
#include <iomanip>
using namespace std;
enum triangleType {noTriangle, scalene, isoceles, equilateral};
//prototypes
void extern input(float&, float&, float&);
triangleType extern triangleShape(float, float, float);
/*void extern output (float, float, float);*/
void extern myLabel(const char *, const char *);
#endif // HEADER_H_INCLUDED
主要功能
//8.1 main
// this progam...
#include "header.h"
int main()
{
float sideLength1, sideLength2, sideLength3;
char response;
do //main loop
{
input (sideLength1, sideLength2, sideLength3);
triangleShape (sideLength1, sideLength2, sideLength3);
//output (sideLength1, sideLength2, sideLength3);
cout << "\nAny more triangles to analyze? (y,n) ";
cin >> response;
}
while (response == 'Y' || response == 'y');
myLabel ("8.1", "2/11/2011");
return 0;
}
triangleShape塑造
# include "header.h"
triangleType triangleShape(sideLenght1, sideLength2, sideLength3)
{
triangleType triangle;
return triangle;
}
Doh!它總是像這樣愚蠢的東西不是嗎?謝謝 – darko 2011-02-05 23:29:00