December 2008

You are currently browsing the monthly archive for December 2008.

Q. How do I change MySQL root password under Linux, FreeBSD, OpenBSD and UNIX like operating system over ssh / telnet session?

A. Setting up mysql password is one of the essential tasks. root user is MySQL admin account. Please note that Linux / UNIX login root account for your operating system and MySQL root are different. They are separate and nothing to do with each other (indeed some admin removes root account and setup admin as mysql super user).
mysqladmin command to change root password

Read the rest of this entry »

Related posts

Tags: , , , ,

C++ Friend Functions

A class can allow non-member functions and other classes to access its own private data, by making them as friends. This part of C++ tutorial essentially gives two important points.

  • Once a non-member function is declared as a friend, it can access the private data of the class
  • similarly when a class is declared as a friend, the friend class can have access to the private data of the class which made this a friend

Here is an example

/* Onur AKTAS – alonon.net
 * 15/12/2008
 * Friend Functions
 */

#include <iostream>
using namespace std;
class INTEGER
{
        int num; // private variable
public:
        INTEGER(int n=0) {num = n;} // constructor to assign n to num
        friend void add(INTEGER &x,INTEGER &y); // this is friend function, it is not a member function, and can not write in class
};
void add (INTEGER &x,INTEGER &y) // do not write friend at the begining
{
  cout<<"Addition is: "<<x.num+y.num<<endl; // plus x’s num with y’s num
}
int main ()
{
        INTEGER x(5);
        INTEGER y(6);
        add(x,y);
        return 0;
}

Related posts

Tags: , , ,