Search Results

Search found 2 results on 1 pages for 'dahlia'.

Page 1/1 | 1 

  • Few Basic Questions in Overriding

    - by Dahlia
    I have few problems with my basic and would be thankful if someone can clear this. What does it mean when I say base *b = new derived; Why would one go for this? We very well separately can create objects for class base and class derived and then call the functions accordingly. I know that this base *b = new derived; is called as Object Slicing but why and when would one go for this? I know why it is not advisable to convert the base class object to derived class object (because base class is not aware of the derived class members and methods). I even read in other StackOverflow threads that if this is gonna be the case then we have to change/re-visit our design. I understand all that, however, I am just curious, Is there any way to do this? class base { public: void f(){cout << "In Base";} }; class derived:public base { public: void f(){cout << "In Derived";} }; int _tmain(int argc, _TCHAR* argv[]) { base b1, b2; derived d1, d2; b2 = d1; d2 = reinterpret_cast<derived*>(b1); //gives error C2440 b1.f(); // Prints In Base d1.f(); // Prints In Derived b2.f(); // Prints In Base d1.base::f(); //Prints In Base d2.f(); getch(); return 0; } In case of my above example, is there any way I could call the base class f() using derived class object? I used d1.base()::f() I just want to know if there any way without using scope resolution operator? Thanks a lot for your time in helping me out!

    Read the article

  • Passenger: "Missing these required gems redgreen"

    - by Michael Stum
    Hello, total ruby newbie, trying to setup a Rails/MongoDB application on Mac OS X Snow leopard. Installed Ruby 1.9.1 and RubyGems 1.3.7, which ruby and which gem point to the same directory. I'm using the Snow Leopard built-in apache and Passenger 2.2.11. I'm using the rails template from the mongo-site which seems to work okay overall. The exact error that passenger gives me is: /Users/User/Sites/feuerapp/vendor/rails/railties/lib/rails/gem_dependency.rb:119:Warning: Gem::Dependency#version_requirements is deprecated and will be removed on or after August 2010. Use #requirement **Notice: C extension not loaded. This is required for optimum MongoDB Ruby driver performance. You can install the extension as follows: gem install bson_ext If you continue to receive this message after installing, make sure that the bson_ext gem is in your load path and that the bson_ext and mongo gems are of the same version. Missing these required gems: redgreen You're running: ruby 1.9.1.376 at /usr/local/bin/ruby rubygems 1.3.7 at /Users/User/.gem/ruby/1.9.1, /usr/local/lib/ruby/gems/1.9.1 Runrake gems:installto install the missing gems. The weird thing is that redgreen is installed and looks fine to me: Dahlia:feuerapp User$ ls -la vendor/gems/ total 0 drwxr-xr-x 7 User staff 238 May 18 22:56 . drwxr-xr-x 5 User staff 170 May 18 23:00 .. drwxr-xr-x 11 User staff 374 May 18 22:56 factory_girl-1.2.4 drwxr-xr-x 11 User staff 374 May 18 22:56 mocha-0.9.8 drwxr-xr-x 7 User staff 238 May 18 22:56 mongo_mapper-0.7.6 drwxr-xr-x 7 User staff 238 May 18 22:56 redgreen-1.2.2 drwxr-xr-x 11 User staff 374 May 18 22:56 shoulda-2.10.3 Commenting out this line in environment.rb "solves" the issue, but that's not really want I want: config.gem 'redgreen' I don't understand anything of gems yet, but from my limited understanding, redgreen should be there and found?

    Read the article

1