Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9193913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:16:41+00:00 2026-06-17T21:16:41+00:00

I am having issues creating an object for my class, I am getting errors

  • 0

I am having issues creating an object for my class, I am getting errors trying to create the class object with the defined data members.

// class header for employee
#pragma once
#include <string>
#include <iostream>
class Employee
{
private:
    std::string name;
    int empnum;
    std::string address;
    std::string phone;
    double hourwage;
    double hoursworked;
public:
    Employee(void);
    Employee(int, std::string , std::string, std::string, double, double);
    double gethourwage () const;
    double gethoursworked () const;
    double printcheck () const;
    std::string getphone() const;
    std::string getname() const;
    std::string getaddress() const;
};
// end of header

// employee class.cpp
#include "Employee.h"
#include <string>
#include <iostream>

Employee::Employee(void)
{
    int empnum = 0;
    double hourwage = 0.0;
    double hoursworked = 0.0;
}
Employee::Employee(int num, std::string nme, std::string addres, std::string phon, double hourpay, double hrswrked)
{
    num = empnum;
    nme = name;
    addres = address;
    phon = phone;
    hourpay = hourwage;
    hrswrked = hoursworked;
}

double Employee::gethourwage() const
{
    return hourwage;
}
double Employee::gethoursworked() const
{
    return hoursworked;
}
double Employee::printcheck() const
{
    double pay = 0.0;
    double hrspay = hourwage;
    double hrswork = hoursworked;
    return hoursworked;

}
// end of employee.cpp
// main
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <string>
#include "Employee.h"

using namespace std;
int main( )
{
    int num1 = 10210;
    double hourwage = 20.2;
    double hourworked = 32.3;
    string steve;
    Employee emp(num1, steve, 58s200w, 90210, hourwage, hourworked);
    cout << "" << emp.getaddress();

    system("PAUSE");
    return 0;
} // end of main

“Employee emp(num1, steve, 58s200w, 90210, hourwage, hourworked);” towards the bottom is the line I am having the issue with. I am not sure if I am entering it in the wrong order, or something else.

Thanks in advance for any help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T21:16:42+00:00Added an answer on June 17, 2026 at 9:16 pm

    You should enter strings in double quotes:

    Employee emp(num1, "steve", "58s200w", "90210", hourwage, hourworked);
    

    Edit 1 (tried to explain the difference between const char * and std::string, as @Alex suggested)

    Literal strings in the snippet above are of type const char *, which is a low-level entity inherited from the C language. const char * is a pointer to memory area which holds consecutive values of type const char.

    std::string is a higher-level wrapper around C-style strings intended to provide more «user-friendly» API and solve some problems of C-style strings (e.g., dynamic allocation and automatic memory cleanup).

    Because the std::string class has a constructor which takes a const char * parameter, literal strings passed to the Employee constructor are implicitly converted to std::string‘s

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having issues with data persisting inside of multiple instances of objects I'm creating.
I am having issues creating multiple independent SlickGrid grids from the same object (that
I am having issues creating a simple 2D scene with Three.js. I would like
Im having issues getting this to work, maybe its not even possible? I have
I'm creating a shopping cart application and I'm having some issues with implementing a
I'm having issues in creating event handler that will be triggered while user moves
in my ASP.NET application, I am creating a new class to handle errors in
I'm having issues getting my controller to recognize the subclass model on a postback.
Im having some issues creating an array of objects in javascript Please see my
I'm having an issue creating an object in the correct format when adding to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.