I need help writing a program in c++ where i have to write 3 different programs, a webcounter.cpp,webcounter.h, and test_prgm.cpp.So then i have to creat a makefile to compile them together, and the result of the program is "When I create the the counter, I would like to be able to set the value of the counter. Second, I need to be able to tell it "hit" and have it increment. Finally, I should be able to "reset" the counter, and "get" the current
number of hits from it." it has to be a header file, and webcounter.cpp has my functions from my header file in it, and test_prgm.cpp is my int main()

Define "help", because it sounds a lot like you want us to do your homework for you.

i mean help as like how should i set it up and the functions i need to call. i created the three files that i need but when i try and creat my make file it prints this out "make: Warning: File `Makefile' has modification time 658 s in the future
g++ -c test_pgrm.cpp
g++: error: test_pgrm.cpp: No such file or directory
g++: fatal error: no input files
compilation terminated.
make: *** [test_prgm.o] Error 1"
and i dont know what this means. I'm in intro and my teacher doesn't explain it that much

Here's a pro tip for when you're first starting out. If you need to modularize files, start by putting it all in a single file, like main.cpp, and get the program working. Then you can modularize it by moving functions to other files and creating headers to declare those functions.

This way you can avoid the nuances of structure (ie. gluing multiple files together) when you're still struggling with the basic functionality.

ok cool thanks.
this is my webcounter.h

#ifndef WEBCOUNTER_H
#define WEBCOUNTER_H
#include<iostream>


class webcounter{
public:
  void display();

private:
int get ();
int hit();
int reset();
int set;

};
#endif

this is my webcounter.cpp

#include "webcounter.h"

void webcounter::display()
{ 
  int set();
  cout << " Your webcounter is " << set << endl;

  int hit();
  set++; 

  int get();
  set;

  int reset()
   set=0;
}

this is my test_prgm.cpp

// Adam Meyer
// Project 1
// 9/25/13

#include <iostream>
#include "webcounter.h"
using namespace std;

class webcounter::display();

int main() 
{
int set;

  cout << " Hello. " << endl;
  cout << " Abstraction and encapsulation are the cornerstone of good code." << endl;
  cout << " Please set the Webcounter: " << endl;
  cin >> set;
 webcounter.set;

  return 0;
}

what am i doing wrong with my code? I just am wondering what things do i need to change or input so that it will do what i want it to do?

Let's start with this: what is set? Make up your mind, is it a function, a data member, or a local variable? What do you want to do with it? Right now your code pretty much depends on the compiler being psychic every other line.

my set should be the number that the user gives me in my main. and then when the user types hit it has to increment by 1, and when they type get it spits out how many times they typed hit, and then reset takes it back to 0

I tried what you said to put it all in one main.cpp and I'm just not understanding how its not working.

#include <iostream>
#include "webcounter.h"
using namespace std;

class webcounter(int set)
{
  int set,hit,get,reset;
  set=set;
  hit=set++;
  get=set;
  reset=0;
}

int main() 
{
int set;

  cout << " Hello. " << endl;
  cout << " Abstraction and encapsulation are the cornerstone of good code." << endl;
  cout << " Please set the Webcounter: " << endl;
  cin >> set;
  cout << " Your set Webcounter is " << webcounter.set << endl;

  webcounter.hit(int set++)
    cout << webcounter.set << endl;

  webcounter.get(int get)
    cout << webcounter.get << endl;

  webcounter.reset(int reset)
    cout << webcounter.reset << endl;

  return 0;
}

So, have you learned C++ at all, or are you just guessing as to what the syntax is? Because your code is very clearly nonsensical. At this point I'd recommend re-reading the chapter on functions and classes in your book until you understand what you're doing wrong.

I'd also strongly recommend using unique names for each unique variable, because your re-use of set is sure to cause heartache.

no i haven't.i am in the intro class. thats why i was asking for help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.