Jump to content

  • Log In with Google      Sign In   
  • Create Account

//Lumia

Member Since 22 Dec 2012
Online Last Active Today, 01:21 PM

#5124231 Accessing base class functions

Posted by //Lumia on 16 January 2014 - 04:01 PM

Hi,

 

I'm actually not sure if C# provides namespaces because there should be packages. But they are aiming at the same goal anyway.

So if you are working with a base class from another namespace make sure to "mark" this in your code as well.

Here is a short example:

#include <iostream>

namespace cars {
class Car {
public:
	void move() {
		std::cout << "The CAR is moving" << std::endl;
	}
};
};

class Audi:public cars::Car {
public:
	void someFunction() {
		move();
		cars::Car::move();
	}

	void move() {
		std::cout << "The Audi is moving" << std::endl;
	}
};


int main(int argc, char* argv[]) {

	Audi audi = Audi();
	audi.someFunction();

	return 0;
}

The Code above results in:

The Audi is moving.

The CAR is moving.

 

But as long as you're not overwriting the base-class method it should be called anyway because you derived from that class.

#include <iostream>

namespace cars {
class Car {
public:
	void move() {
		std::cout << "The CAR is moving" << std::endl;
	}
};
};

class Audi:public cars::Car {
public:
	void someFunction() {
		move();
		cars::Car::move();
	}
};


int main(int argc, char* argv[]) {

	Audi audi = Audi();
	audi.someFunction();

	return 0;
}

This code results in:

The CAR is moving,

The CAR is moving.

 

In addition to that i think that this is a bad code practice. Please correct me if i'm wrong but i can't figure out a situation that forces me to do things like that (I'm either overwriting the method or using the derived one)




#5118241 Can someone make this VS 2010?

Posted by //Lumia on 19 December 2013 - 03:37 PM

Hi again,

 

my suspicion is that you are not compiling the code with the MinGW compiler as mentioned in the Readme of the repository.

If so then the built-in VS compiler will try to do the job.

Referring to this Thread (sorry for cross-site linking) http://stackoverflow.com/questions/8525470/porting-c-compilation-from-mingw-to-visualstudionmake there can be several situations that are not covered in the standard or differ depending on the standard that is used.

 

So if you aren't compiling with MinGW as it is recommended please get active and do so.

You can ignore my post if you're already using MinGW.

 




#5118191 Can someone make this VS 2010?

Posted by //Lumia on 19 December 2013 - 12:51 PM

Hi there,

 

if I hit the link in your initial post I am redirected to the projects page on github.

There is a Readme on the lower part of the site. It says clearly that this project has external dependencies including "libcurl" and "jansson".

Furthermore there are Links offered so you can go there and download the libs mentioned above:

So import the project and download these 2 libs. After that you have to link against them. You are doing this by changing your project properties.

If you have finished this steps everything should be fine and you are ready to build the project.

 

I hope this helps you out.




PARTNERS