Hello All,
I'm compiling my program, and i keep getting this error:
obj/Debug/fubar.o||In function `fubar::fubarl(int*, int*)':|
/home/miguel/Documents/pointersandref/fubar.cpp|7|multiple definition of `fubar::fubarl(int*, int*)'|
obj/Debug/fubar.o:/home/miguel/Documents/pointersandref/fubar.cpp|7|first defined here|
||=== Build finished: 2 errors, 0 warnings ===|
This is my complete source code
fubar.cpp
#include <string.h>
#include <stdio.h>
#include "fubar.h"
void fubar::fubarl(int *foo, int *bar)
{
int drawx = 0;
int drawy = 0;
static int timesrun = 0;
while(drawx < *foo)
{
printf("*");
drawx++;
timesrun++;
if (timesrun = *foo)
{
printf("\n");
timesrun = 0;
}
}
}
fubar.h
#ifndef FUBAR_H_INCLUDED
#define FUBAR_H_INCLUDED
class fubar
{
public:
void fubarl(int *foo, int *bar);
private:
};
#endif // FUBAR_H_INCLUDED
main.cpp
#include <iostream>
#include <string>
#include "fubar.h"
#include <stdlib.h>
#include <ctype.h>
using namespace std;
int main()
{ /*** Starting Values ***/
int x = 0;
int y = 0;
/*** Holds the values entered by the user ***/
int valuex;
int valuey;
/*** Pointers to our values ***/
int *Px = &x;
int *Py = &y;
cout << "Please enter value for width of a rectangle(Between 3 and 20):\n";
cin >> valuex;
if (valuex >= 3 && valuex <= 20)
{
/*** Just a place holder lololol ***/
valuex = valuex;
}
else
{
cout << "Error, bad input!!!\n";
}
cout << "Please enter value for height of a rectangle(Between 5 and 50):\n";
cin >> valuey;
if (valuey >= 5 && valuey <= 50)
{
/*** Just a place holder lololol ***/
valuey = valuey;
}
else
{
cout << "Error, bad input!!!\n";
}
fubar newbar;
newbar.fubarl(Px, Py);
return 0;
}
How do i fix this, and explain why this happens