I'm trying to write this code and having trouble compiling the code I've tried everthing but doesn't seem to want to work right, can you find any thing wrong in my code?

{// Overtime Pay Structures.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using std::cout;
using std::endl;
using std::cin;
//Definition of a struct to represent overtime pay calculator
struct overtime
{
    char Name[80];
    int Hours;
    int Wage;
};
class OTpay
{
public:
    double m_hours;
    double m_wage;
    double m_name;
};
OTpay::OTpay();
int _tmain(int argc, _TCHAR* argv[])
{

    OTpay person1;

    double otXpay = 0.00;
    double otHours = 0.0;
    person1.m_hours = 42.0;
    person1.m_name = ("John");
    person1.m_wage = 21.55;
//Calcualte overtime pay and hours for person1
    otXpay = m_wage-1.5;
    otHours = m_hours+40;
        cout<<endl
            <<"Person 1 Name is: " <<person1.m_name;
        cout<<endl
            <<"Person 1 Overtime Hours are: " <<otHours;
        cout<<endl
            <<"Person 1 OVertime Pay is: " <<otPay;
        cout<<endl;
    return 0;
}

your mistake is you used m_wage and m_hours directly....but you can acces them through object only so you have to give person1.m_wage and person1.m_hours in 34 and 35 lines....
and the second thing is in the 22 line...
you have to declare that inside the class....
and the third thing you can also use simple main() function instead of _tmain();
so you may try this code given below....I have modifed ur code wid small changes......

MODIFED PROGRAM:

// Overtime Pay Structures.cpp : Defines the entry point for the console application.

#include<iostream.h>
#include<conio.h>
using std::cout;
using std::endl;
using std::cin;
//Definition of a struct to represent overtime pay calculator
struct overtime
{
char Name[80];
int Hours;
int Wage;
};
class OTpay
{
public:
double m_hours;
double m_wage;
char *m_name;
OTpay()
{
       m_wage=0;
       m_hours=0;
}
};

int main()
{
OTpay person1;
double otXpay = 0.0;
double otHours = 0.0;
person1.m_hours = 42.0;
person1.m_name = ("John");
person1.m_wage = 21.55;
//Calcualte overtime pay and hours for person1
otXpay = person1.m_wage-1.5;
otHours = person1.m_hours+40;
cout<<endl
<<"Person 1 Name is: " <<person1.m_name;
cout<<endl
<<"Person 1 Overtime Hours are: " <<otHours;
cout<<endl
<<"Person 1 OVertime Pay is: " <<otXpay;
cout<<endl;
getch();
}
  1. Remove the opening brace '{' on line 1
  2. OTpay.m_name is a pointer. You can't assign anything to it except an address: line 32 is nonsense.
  3. Add #include <string> after line 2
  4. Change line 18 to std::string m_name;
  5. Not sure what you're trying to do on line 22: OTpay::OTpay();

Not sure what you're trying to do on line 22: OTpay::OTpay();

I think he was trying to make a default constructor for the class OTpay.
Like prakash4 said that it should be inside the class.

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.