Monthly Archive for April, 2010

Red Hat Enterprise Linux 6 Beta + Grub 2

Yesterday I downloaded and installed RHEL 6 Beta but I didn’t install the boot loader. I already have Grub 2 installed and set up on my laptop with my other distros and Windows. RHEL 6 Beta uses Grub (Legacy) and this handles graphics different to Grub 2. I’ve been using LFS and CLFS for a while now for development so it’s been a while since I’ve used a full distro, with GUI and wireless an other very nice features (like the spell checker I’m using in FireFox).

Below is the Grub 2 configuration file I use to boot RHEL 6 Beta. I’m assuming you already have Grub 2 installed.

# Begin /boot/grub/grub.cfg

set gfxmode="1280x800x32" # Your resolution
set gfxpayload=keep
insmod gfxterm # Load modules
insmod vbe 

set default=0
set timeout=5
set root=(hd0,3) # Your boot partition

menuentry "Red Hat Enterprise Linux 6 Beta" {
  linux /vmlinuz-2.6.32-19.el6.x86_64 root=/dev/sda9 # Your root device
  initrd /initramfs-2.6.32-19.el6.x86_64.img
}

# End /boot/grub/grub.cfg

It took me about a day to work this out so I hope this helps you.

Jon~

C++ Aggregation Assocation

Hello all. I created the program at the bottom as a test as I was having problems with Aggregation Assocation in my assignment. The program below has the person class that we created in the last post but now it also has a new link class with two functions. The first function sets the pointer to the person, the second increases the person’s age by one. You can see that I have commented out the orginal command that sets the person’s age.

A pointer is a link to the RAM address of something else, in this case a instance of the person class. You access a pointer’s public functions / variables by the -> symbol. So pointer->setValue(newValue) would run the setValue function of what the pointer is connected too.

A Aggregation Assocation is a connection between two classes that do not own one another. For example a pet belongs to it’s owner but a student does not belong to a school as student and school are both independant entities that are connected.

This is something I did quickly and thought I’d stick online so if you have any questions leave a comment and I’ll get back to you.

#include <iostream>
#include <string>

using namespace std;

class person
{
  private:
    int age;
    string name;

  public:
    // Constructors
    person();
    person(string newName, int newAge);

    // Accessors
    string getName() { return name; };
    int getAge() { return age; };
    // datatype getVariable() { return variable; };

    // Mutators
    void setName(string newName);
    void setAge(int newAge);
    // void setVariable(datatype newVariable);

};

person::person()
{
  name = "Stranger";
  age = 100;
}

person::person(string newName, int newAge)
{
  name = newName;
  age = newAge;
}

void person::setName(string newName)
{
  name = newName;
}

void person::setAge(int newAge)
{
  age = newAge;
}

///////////////////////////////////////////////////
class pointerClass
{
  private:
    person *link; // pointer to a person

  public:
    void setLink(person * newLink); // set the pointer to a person you've created
    void incAge(); // increase their age by one

};

// set the pointer to a person you've created
void pointerClass::setLink(person * newLink)
{
  link = newLink;
}

// Increse their age by one.
void pointerClass::incAge()
{
  int temp = link->getAge(); //get Age
  // cout << "temp: " << temp << endl; // output orginal age
  link->setAge(++temp); // inc and set new age.
  // cout << "temp: " << temp << endl; // output new age
}

///////////////////////////////////////////////////
int main()
{
  pointerClass myLink;
  person steve("Steve", 20);
  myLink.setLink(&steve);
  cout << steve.getAge() << endl;
  // steve.setAge(21);
  myLink.incAge();
  cout << steve.getAge() << endl;
}