것은

2012-05-19 4 views
0

이 프로그램에 대한 오류 메시지를 .. 설명해주십시오것은

#include <iostream> 
using namespace std; 
class copyConst 
{ 

    private: 
    int someVal; 
    public: 
    copyConst(const copyConst &objParam) 
    { 
     someVal = objParam.someVal; 
    } 
    copyConst() 
    { 
     someVal = 9; 
    } 
    copyConst& operator=(const copyConst &objParam) 
    { 
     if (this == &objParam) 
      return *this; 

     someVal = objParam.someVal; 
     return *this; 
     } 
    }; 

int main(int argc, char **argv) 
{ 
    copyConst obj1; 
    copyConst obj2(obj1); 
    copyConst obj3 = obj1; 
    copyConst obj4; 
    obj4 = obj1; 


    return 0; 
} 

오류 메시지 :

GCC는 "" "제목"untitled.cpp -o -Wall (의 디렉토리 : /home/rwik/Documents) untitled.cpp : 'int main (int, char **)': untitled.cpp : 53 : 12 : 경고 : 변수 'obj3'이 설정되었지만 사용되지 않음 [ 혼란스런 변수] /tmp/ccUIyRPg.o : 기능 있음 __static_initialization_and_destruction_0(int, int)': untitled.cpp:(.text+0x8a): undefined reference to std :: ios_base :: Init :: Init() 'untitled.cpp :(. text + 0x8f) : undefined `std :: ios_base :: Init :: ~ Init()'에 대한 참조 컴파일이 실패했습니다. collect2 : LD는 g++하지 gcc를 사용

답변

-1

두 가지 유형의 경고 메시지가 있습니다. 두 번째는 때문에 GCC에 연결 플래그 누락입니다 :.. gcc -lstdc++ -Wall -o "untitled" "untitled.cpp" (또는 동등한 g++ -Wall -o "untitled" "untitled.cpp되지 않은 변수에 대한

첫 번째 경고는 난 그런 경우를 들어 선언하지만, 다른 곳에서는 사용하지 않는 때문에 obj3 변수 (void)obj3; 문을 사용하여 그러한 경고 메시지를 회피하십시오.

1

컴파일 1 개 종료 상태를 반환했습니다. C 코드가 아니라 C++ 코드가 있습니다.

클래스 코드와 아무 관련이 없습니다.

+0

이상한 downvote, 대답은 완전히 정확합니다! +1 보상합니다. – juanchopanza