2013-02-27 45 views
1

鑑於打印出屏幕矩形的其餘兩個邊時,兩條邊作爲參數給出一個函數的定義:錯誤的引用:

static void restPuncte (Punct &x, Punct &y); 

及其實施:

void restPuncte (Punct &x, Punct &y) 
{ 
    Punct c; 
    c.MutaX(x.GetX()); 
    c.MutaY(y.GetY()); 

    Punct d; 
    d.MutaX(y.GetX()); 
    d.MutaY(x.GetY()); 

    std::cout << "Punctul C este:" << c << std::endl; 
    std::cout << "Punctul D este:" << d << std::endl; 
} 

主我得到試圖建立項目時出現以下錯誤:

"Punct::restPuncte(Punct&, Punct&)", referenced from: 

主要WO可以是:

#include <iostream> 
#include "punct.h" 

using namespace std; 

int main() 
{ 

    Punct firstPoint(1,2); 

    Punct thirdPoint(4,3); 

    cout << "Determinarea celorlalte doua colturi" << endl; 
    cout << "Cele doua puncte sunt:" << firstPoint << " si " << thirdPoint <<endl; 
    Punct::restPuncte(firstPoint,thirdPoint); 


    return 0; 
} 

你能告訴我什麼是我做錯了嗎?謝謝!

+0

錯誤的其餘部分是什麼? – Corbin 2013-02-27 16:41:18

回答

3
void restPuncte (Punct &x, Punct &y) 

是不一樣的

void Punct::restPuncte (Punct &x, Punct &y) 

你定義一個免費的功能,和你的static方法仍然是不確定的。

+0

哦,傻了。謝謝! – Teodora 2013-02-27 16:45:25

+0

@Teodora cu placere。 – 2013-02-27 17:13:40