Archive for July, 2013

We are living in the Era of high technologies and quick progress, where if you stop for a second you could be lost in the past. Such ideas come into my mind each and every day, the World is moving forward with the speed of light and probably the technological singularity will come soon. In my opinion in the nearest 20-30 years. It means that the human brain will not be able to be in time with the technological progress, and possibly our generation will face to the post high technology Era.

Talking about my nearest future and my interests in the programming world is a partly secret topic of discuss:) I like the progress of post computer devices, such as mobile phones, tablets, glasses, watches, e-screens and more. This topic is the most interesting for me, and hopefully in the nearest future I would be somewhere inside that sphere! Specifically, software development for post computer devices is my hobby, and if will talk even more specifically, then it is space-directed software for post computer devices, probably even for general audience, but for austranauts or space ships. Ahhhh…thats just dreams…but they are so bright and I’m looking forward to them:)

I think that the World around us is completely dependent on computers and other kinds of electronic devices, and thats why I can say that the future already came, but the society still waiting for it…Humanity should realize that the technology progress is completely unstoppable and that because of this we should first take a look at ecology of our mother land, to make it more safe and more acceptable to live for every human on planet. And of course to make it last for the long time…

Hope that people around and me personally will try to make this World better for everyone and for the Earth specifically!:)

Advertisements

Tried to resolve the OOP344 exercise with multi-inheritance (using templates) and after the compilation got this error.
Could anyone help me to figure out the error reason?!
Link to the initial files on github.

  main.cpp
main.obj : error LNK2001: unresolved external symbol "private: static unsigned int Base::count" (?count@?$Base@ViSpeaker@@@@0IA)
main.obj : error LNK2001: unresolved external symbol "private: static unsigned int Base::count" (?count@?$Base@ViBell@@@@0IA)
Project2.exe : fatal error LNK1120: 2 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Basically, my headers:
File — Base.h

#ifndef __BASE__
#define __BASE__
#include "iBase.h"

template <class T = iBase>
class Base : public T
   {
   private:
      static unsigned int count;

      unsigned int id;
   protected:
   public:
      Base() : id(count++) {}
      unsigned int getID() {return id;}
   };

#endif

File — Bell.h

#ifndef __BELL__
#define __BELL__
#include "iBell.h"
#include "SoundMaker.h"

template <class T = iBell>
class Bell : public SoundMaker<T>
   {
   private:
   protected:
   public:
      Bell() : SoundMaker<T>() {sound = "Ding";}
      void switchHammer()
         {
         if(sound == "Ding")
            sound = "Dong";
         else
            sound = "Ding";
         }
   };

#endif

File — SoundMaker.h

#ifndef __SOUND_MAKER__
#define __SOUND_MAKER__
#include
#include
#include "iSoundMaker.h"
#include "Base.h"

template <class T = iSoundMaker>
class SoundMaker : public Base<T>
   {
   private:
   protected:
      std::string sound;
   public:
      SoundMaker() : Base<T>(), sound("Bang") {}
      void playSound()
	  {
		  std::cout << sound << "\n";
	  }
   };

#endif

File — Speaker.h

#ifndef __SPEAKER__
#define __SPEAKER__
#include "iSpeaker.h"
#include "SoundMaker.h"

template <class T = iSpeaker>
class Speaker : public SoundMaker<T>
   {
   private:
   protected:
   public:
      Speaker() : SoundMaker<>() {}
      void increaseVolume()
         {
         this->sound += "!";
         }
   };

#endif

And finally my main():

#include "Speaker.h"
#include "Bell.h"

template<class T>
unsigned int Base::count = 0; //static initialization WARNING!
int main()
   {
   Speaker<> a;
   Speaker<> b;

   Bell<> c;

   a.playSound();
   a.increaseVolume();

   b.increaseVolume();
   b.playSound();

   c.playSound();
   c.switchHammer();
   c.playSound();

   std::cout << a.getID() << " " << b.getID() << " " << c.getID();
   return 0;
   }