今度はリンカ ツール エラー LNK2019とグローバル変数に悩まされています。
どうすればよろしいのでしょうか?
以下問題のソースコードとエラーメッセージ
bitmap.hの中身。
#ifndef BITMAP_GAME
#define BITMAP_GAME
template <class type>
class Graphics
{
public:;
void screen_up();
void mario();
};
class Bitmap
{
protected:
int z;
public:
int get_z();
void change_z(const int& set_z);
};
static Graphics<Bitmap> graphics;
#endif
bitmap.cppの中身
#include "bitmap.h"
template <class type>
void Graphics<type>::screen_up()
{
};
template <class type>
void Graphics<type>::mario()
{
};
int Bitmap::get_z()
{
return z;
};
void Bitmap::change_z(const int& set_z)
{
z=set_z;
};
scene.hの中身
#ifndef SCENE_GAME
#define SCENE_GAME
#include "bitmap.h"
class Scene_Base
{
public:
virtual void main();
};
#endif
scene.cppの中身
#include "scene.h"
void Scene_Base::main()
{
graphics.screen_up();
graphics.mario();
};
リンカ ツール エラー LNK2019とグローバル変数について。
Re:リンカ ツール エラー LNK2019とグローバル変数について。
エラーメッセージを忘れていました。
コンパイルしています...
bitmap.cpp
main.cpp
scene.cpp
コードを生成中...
マニフェストをリソースにコンパイルしています...
Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
Copyright (C) Microsoft Corporation. All rights reserved.
リンクしています...
scene.obj : error LNK2019: 未解決の外部シンボル "public: void __thiscall Graphics::mario(void)" (?mario@?$Graphics@VBitmap@@@@QAEXXZ) が関数 "public: virtual void __thiscall Scene_Base::main(void)" (?main@Scene_Base@@UAEXXZ) で参照されました。
scene.obj : error LNK2019: 未解決の外部シンボル "public: void __thiscall Graphics::screen_up(void)" (?screen_up@?$Graphics@VBitmap@@@@QAEXXZ) が関数 "public: virtual void __thiscall Scene_Base::main(void)" (?main@Scene_Base@@UAEXXZ) で参照されました。
C:\Users\kimura keigo\Documents\Visual Studio 2008\Projects\実験_2\Debug\実験_2.exe : fatal error LNK1120: 外部参照 2 が未解決です。
コンパイルしています...
bitmap.cpp
main.cpp
scene.cpp
コードを生成中...
マニフェストをリソースにコンパイルしています...
Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
Copyright (C) Microsoft Corporation. All rights reserved.
リンクしています...
scene.obj : error LNK2019: 未解決の外部シンボル "public: void __thiscall Graphics::mario(void)" (?mario@?$Graphics@VBitmap@@@@QAEXXZ) が関数 "public: virtual void __thiscall Scene_Base::main(void)" (?main@Scene_Base@@UAEXXZ) で参照されました。
scene.obj : error LNK2019: 未解決の外部シンボル "public: void __thiscall Graphics::screen_up(void)" (?screen_up@?$Graphics@VBitmap@@@@QAEXXZ) が関数 "public: virtual void __thiscall Scene_Base::main(void)" (?main@Scene_Base@@UAEXXZ) で参照されました。
C:\Users\kimura keigo\Documents\Visual Studio 2008\Projects\実験_2\Debug\実験_2.exe : fatal error LNK1120: 外部参照 2 が未解決です。
Re:リンカ ツール エラー LNK2019とグローバル変数について。
確かに、文法上は間違いではなかったですね(そうなのか?)
コードを全て開示していただかないと、これ以上私はわかりませんね。
(グローバル変数に悩まされているということですが、そのグローバル変数も見当たりませんし。)
コードを全て開示していただかないと、これ以上私はわかりませんね。
(グローバル変数に悩まされているということですが、そのグローバル変数も見当たりませんし。)
Re:リンカ ツール エラー LNK2019とグローバル変数について。
一番上の文章の27行目あたりに
static Graphics<Bitmap> graphics;
と書いてあるはずなんですが・・・。
これがグローバル変数のはずなんですけど・・・。
static Graphics<Bitmap> graphics;
と書いてあるはずなんですが・・・。
これがグローバル変数のはずなんですけど・・・。
Re:リンカ ツール エラー LNK2019とグローバル変数について。
template はヘッダファイルに移動。
あと、
あと、
static Graphics<Bitmap> graphics;これは、本当にヘッダファイルに書く必要あるの?