static member of class

How should I define static member of class in this case?
Object::tex.loadMedia didn't work
Object.tex.loadMedia didn't work
LTexture Object::tex.loadMedia didn't work
LTexture Object.tex.loadMedia didn't work

Object.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  #ifndef Object_H
#define Object_H

#include <SDL.h>
#include "LTexture.h"

class Object
{
public:
	Object();
	~Object();

	static LTexture tex;
	
	int getHeight();
	int getWidth();

private:
	int x, y;
	int oHeight;
	int oWidth;

	SDL_Rect oCollider;
};


#endif // !Object_H


LTexture.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#ifndef LTexture_H
#define LTexture_H

#include <SDL.h>
#include <SDL_image.h>
#include <string>
#include <iostream>

class LTexture
{
public:

	LTexture();
	~LTexture();


	bool loadFromFile(std::string path);

	void free();

	void render(int x, int y,int w=0,int h=0);

	int getWidth();
	int getHeight();

private:

	SDL_Texture* mTexture;

	int mWidth;
	int mHeight;
};

#endif // !LTexture_H 

I want to use tex.loadFromFile("path"); I want to put definition of that static member in function loadMedia
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
bool loadMedia()
{
	bool success = true;

	gTextureWoodfloor.loadFromFile("data/Textures/woodfloor.png");
	gracz.tex.loadFromFile("data/Textures/glowa.png");
	//i want to put it here

	Icon = loadSurface("ikona.ico");
	if (Icon == NULL)
	{
		std::cout << "failed loading ikona.ico\n";
		success = false;
	}

	return success;
	}
1
2
3
4
Object::tex.loadMedia didn't work
Object.tex.loadMedia didn't work
LTexture Object::tex.loadMedia didn't work
LTexture Object.tex.loadMedia didn't work


tex doesn't have a method called loadMedia

You can call : Object::tex.loadFormFile("Filename");
Ohh i meant loadFromFile every time there. But the biggest problem is that when I declare extern Object Walls[4] in header.h and then write Object Walls[4] in header.cpp and add Object::tex.loadFormFile("Filename"); to loadMedia ( it is just normal function not method of any class) I get
1
2
error LNK2001: unresolved external symbol "public: static class LTexture Object::tex" (?tex@Object@@2VLTexture@@A)
fatal error LNK1120: 1 unresolved externals
Topic archived. No new replies allowed.