>how do i do this?
Code:
// pair.h
#ifndef PAIR_H__
#define PAIR_H__
class Pair
{
int aNum1;
int aNum2;
public:
Pair (int num1, int num2);
Pair ();
void output ();
void setNum1 (int num);
void setNum2 (int num);
};
#endif
Code:
// pair.c
#include <iostream.h>
#include "header.h"
Pair :: Pair (int num1, int num2) {
aNum1 = num1;
aNum2 = num2;
}
Pair :: Pair () {
aNum1 = 0;
aNum2 = 0;
}
void Pair :: output () {
cout << aNum1 << " " << aNum2 << endl;
}
void Pair :: setNum1 (int num) {
aNum1 = num;
}
void Pair :: setNum2 (int num) {
aNum2 = num;
}
Code:
// main.c
#include <iostream.h>
#include "header.h"
int main () {
Pair numPair (12, 34);
numPair.output ();
numPair.setNum2 (21);
numPair.output ();
return 0;
}
-Prelude