Skip to content

Instantly share code, notes, and snippets.

@Chavao
Created May 19, 2012 02:12
Show Gist options
  • Select an option

  • Save Chavao/2728669 to your computer and use it in GitHub Desktop.

Select an option

Save Chavao/2728669 to your computer and use it in GitHub Desktop.
chavao@ubuntu:~/Desktop/cpp/proj$ g++ -c -g rumo.cpp
chavao@ubuntu:~/Desktop/cpp/proj$ g++ -g -g main.cpp
main.cpp: In function ‘int main()’:
main.cpp:8: error: aggregate ‘Rumo r’ has incomplete type and cannot be defined
chavao@ubuntu:~/Desktop/cpp/proj$
#include <iostream>
using namespace std;
class Rumo;
int main()
{
Rumo r;
cout << "Valor: " << r.obterValor() << endl;
return 0;
}
#include <iostream>
using namespace std;
class Rumo
{
private:
int valor;
public:
void setValor(int v);
int obterValor() const;
};
int Rumo::obterValor() const
{
return valor;
}
void Rumo::setValor(int v)
{
valor = v;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment