Debbuging help! Any help appreciated!

//we have to use multiple files for this, this is Seller3.cpp

#include <iostream>
#include <iomanip>
#include <cstring>
#include "Seller3.h"

using std::cout;
using std::endl;
using std::fixed;
using std::left;
using std::right;
using std::setprecision;
using std::setw;


strcpy(Name, "");
SalesTotal = 0;


Seller::Seller(const char* newName, double newSalesTotal)

strcpy(Name, newName);
SalesTotal = newSalesTotal;


char* Seller::getName() const

return const char* Name();


double Seller::getSalesTotal() const
return SalesTotal;


void Seller::getSalesTotal(double newSalesTotal) const
SalesTotal = newSalesTotal;

void Seller::print() const
cout << fixed << setprecision(2);
cout << setw(30) << left << Name << right << setw(9) << SalesTotal;


//second file Seller3.h

#ifndef SELLER3_H
#define SELLER3_H

// FILE: Seller.h
// AUTHOR: your name
// LOGON ID: your z-ID
// DUE DATE: due date of assignment
// PURPOSE: Contains the declaration for the Seller class.
class Seller
// Data members and method prototypes for the Seller class go here

Seller(const char*, double);

char* getName() const;
double getSalesTotal() const;
void getSalesTotal(double) const;
void print() const;


char Name[31];
double SalesTotal;


/*I keep getting errors from lines 33 and 45 of the first file, ever since I added consts to the methods/prototypes i keep getting errors.

Seller3.cpp:33: error: expected primary-expression before "const"

Seller3.cpp:33: error: expected ; before const

Seller3.cpp:45: error: assignment of data-member "Seller:SalesTotal" in read only structure

Any help would be appreciated!!! */
Last edited on
Line 33: You're trying to return a const char * in a function that is typed char *

Change line 33 to:
const char* Seller::getName() const
You need to change the declaration also.

Line 35: Not sure what you're trying to do here. If you're trying to do a cast, you need parens around it, although the cast is not needed. Also, the reference to Name should be a simple array reference, not a function call.
return Name;

Line 45: You've defined getSalesTotal as a const function. That means you can't modify the class. Remove the const on line 43 and in the class delcaration also.

PLEASE USE CODE TAGS (the <> formatting button) when posting code.

Topic archived. No new replies allowed.