473,804 Members | 3,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Student is Desperate

What the heck is wrong with this:

#ifndef POLYNOMIAL_H
#define POLYNOMIAL_H
class Polynomial {
public:
Polynomial();
Polynomial operator+( const Polynomial& ) const; // addition
Polynomial operator-( const Polynomial& ) const; // subtraction
Polynomial operator*( const Polynomial& ); // multiplication
const Polynomial operator=( const Polynomial&);// assignment
Polynomial& operator+=( const Polynomial& );
Polynomial& operator-=( const Polynomial& );
Polynomial& operator*=( const Polynomial& );
void enterTerms();
void printPolynomial () const;
private:
int exponents[ 100 ]; // exponent array
int coefficients[ 100 ]; // coefficients array
void polynomialCombi ne( Polynomial& ); // combine common terms
}; // end class Polynomial
#endif
#include <iostream>

using std::cout;
using std::endl;

#include "Polynomial .h"
int main()
{
Polynomial a, b, c, t;

a.enterTerms();
b.enterTerms();
t = a; // save the value of a
cout << "First polynomial is:\n";
a.printPolynomi al();
cout << "Second polynomial is:\n";
b.printPolynomi al();
cout << "\nAdding the polynomials yields:\n";
c = a + b;
c.printPolynomi al();
cout << "\n+= the polynomials yields:\n";
a += b;
a.printPolynomi al();
cout << "\nSubtract ing the polynomials yields:\n";
a = t; // reset a to original value
c = a - b;
c.printPolynomi al();
cout << "\n-= the polynomials yields:\n";
a -= b;
a.printPolynomi al();
cout << "\nMultiply ing the polynomials yields:\n";
a = t; // reset a to original value
c = a * b;
c.printPolynomi al();
cout << "\n*= the polynomials yields:\n";
a *= b;
a.printPolynomi al();
cout << endl;
return 0;
} // end main
C:\Documents and Settings\Owner\ connie marshall's week 7
homework.cpp(32 ) : fatal error C1083: Cannot open include file:
'Polynomial.h': No such file or directory

The question is:

Using C++ language to complete this homework

1. Develop class Polynomial. The internal representation of a
Polynomial is an array of terms. Each term contains a coefficient and
an exponent. The term

2x4
has the coefficient 2 and the exponent 4. Develop a complete class
containing proper constructor functions as well as set and get
functions. The class should also provide the following overloaded
operator capabilities:

(a) Overload the addition operator (+) to add two Polynomials.
(b) Overload the multiplication operator (*) to multiply two
Polynomials.
(c) Overload the subtraction assignment operator (-) to process two
Polynomials
(d) Overlaod the assignment operator to assign one polynomial to
another
(e) Overload the addition assignment operator (+=), subtraction
assignment operator (-=), and multiplication assignment operator(*=).

I'm going crazy here. Please help.

Aug 11 '06 #1
5 3751
beachlounger wrote:
What the heck is wrong with this:

C:\Documents and Settings\Owner\ connie marshall's week 7
homework.cpp(32 ) : fatal error C1083: Cannot open include file:
'Polynomial.h': No such file or directory
Do you have a file called C:\Documents and Settings\Owner\ Polynomial.h ?

If not, put the stuff between #ifdef and #endif into it, inclusive.
I'm going crazy here. Please help.
Your next tip is to form a study group with your classmates.

--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
Aug 11 '06 #2
* be**********@ao l.com:
What the heck is wrong with this:

#ifndef POLYNOMIAL_H
#define POLYNOMIAL_H
class Polynomial {
public:
Polynomial();
Polynomial operator+( const Polynomial& ) const; // addition
Polynomial operator-( const Polynomial& ) const; // subtraction
Polynomial operator*( const Polynomial& ); // multiplication
const Polynomial operator=( const Polynomial&);// assignment
Polynomial& operator+=( const Polynomial& );
Polynomial& operator-=( const Polynomial& );
Polynomial& operator*=( const Polynomial& );
void enterTerms();
void printPolynomial () const;
private:
int exponents[ 100 ]; // exponent array
int coefficients[ 100 ]; // coefficients array
void polynomialCombi ne( Polynomial& ); // combine common terms
}; // end class Polynomial
#endif
#include <iostream>

using std::cout;
using std::endl;

#include "Polynomial .h"
int main()
{
Polynomial a, b, c, t;

a.enterTerms();
b.enterTerms();
t = a; // save the value of a
cout << "First polynomial is:\n";
a.printPolynomi al();
cout << "Second polynomial is:\n";
b.printPolynomi al();
cout << "\nAdding the polynomials yields:\n";
c = a + b;
c.printPolynomi al();
cout << "\n+= the polynomials yields:\n";
a += b;
a.printPolynomi al();
cout << "\nSubtract ing the polynomials yields:\n";
a = t; // reset a to original value
c = a - b;
c.printPolynomi al();
cout << "\n-= the polynomials yields:\n";
a -= b;
a.printPolynomi al();
cout << "\nMultiply ing the polynomials yields:\n";
a = t; // reset a to original value
c = a * b;
c.printPolynomi al();
cout << "\n*= the polynomials yields:\n";
a *= b;
a.printPolynomi al();
cout << endl;
return 0;
} // end main
C:\Documents and Settings\Owner\ connie marshall's week 7
homework.cpp(32 ) : fatal error C1083: Cannot open include file:
'Polynomial.h': No such file or directory

The question is:

Using C++ language to complete this homework

1. Develop class Polynomial. The internal representation of a
Polynomial is an array of terms. Each term contains a coefficient and
an exponent. The term
You're missing the file [Polynomial.h].

The assignment seems to be to create that file.

And possibly also an implementation file [Polynomial.cpp].
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Aug 11 '06 #3

<be**********@a ol.comwrote in message
news:11******** **************@ m73g2000cwd.goo glegroups.com.. .
>
C:\Documents and Settings\Owner\ connie marshall's week 7
homework.cpp(32 ) : fatal error C1083: Cannot open include file:
'Polynomial.h': No such file or directory

The question is:

Using C++ language to complete this homework
Your assignment really has nothing to do with the error message. Read it.
It says it can't find the file "Polynomial .h". If that file exists, is it
in the correct directory? Is it spelled correctly? Does your compiler know
where to look for it? You may need to add it to your project, or add the
directory where it is stored to some kind of search path in your compiler or
project settings.

Answers to problems like that are best gotten from a newsgroup devoted to
your compiler, not from this language newsgroup.

-Howard

Aug 11 '06 #4

be**********@ao l.com wrote:
I'm going crazy here.

Congratulations !!!

Aug 11 '06 #5
be**********@ao l.com wrote:
What the heck is wrong with this:

#ifndef POLYNOMIAL_H
#define POLYNOMIAL_H
class Polynomial {
public:
Polynomial();
Polynomial operator+( const Polynomial& ) const; // addition
Polynomial operator-( const Polynomial& ) const; // subtraction
Polynomial operator*( const Polynomial& ); // multiplication
const Polynomial operator=( const Polynomial&);// assignment
Polynomial& operator+=( const Polynomial& );
Polynomial& operator-=( const Polynomial& );
Polynomial& operator*=( const Polynomial& );
void enterTerms();
void printPolynomial () const;
private:
int exponents[ 100 ]; // exponent array
int coefficients[ 100 ]; // coefficients array
void polynomialCombi ne( Polynomial& ); // combine common terms
}; // end class Polynomial
#endif
Cut here and paste the above text into Polynomial.h.
>

#include <iostream>

using std::cout;
using std::endl;

#include "Polynomial .h"
int main()
{
Polynomial a, b, c, t;

a.enterTerms();
b.enterTerms();
t = a; // save the value of a
cout << "First polynomial is:\n";
a.printPolynomi al();
cout << "Second polynomial is:\n";
b.printPolynomi al();
cout << "\nAdding the polynomials yields:\n";
c = a + b;
c.printPolynomi al();
cout << "\n+= the polynomials yields:\n";
a += b;
a.printPolynomi al();
cout << "\nSubtract ing the polynomials yields:\n";
a = t; // reset a to original value
c = a - b;
c.printPolynomi al();
cout << "\n-= the polynomials yields:\n";
a -= b;
a.printPolynomi al();
cout << "\nMultiply ing the polynomials yields:\n";
a = t; // reset a to original value
c = a * b;
c.printPolynomi al();
cout << "\n*= the polynomials yields:\n";
a *= b;
a.printPolynomi al();
cout << endl;
return 0;
} // end main
C:\Documents and Settings\Owner\ connie marshall's week 7
homework.cpp(32 ) : fatal error C1083: Cannot open include file:
'Polynomial.h': No such file or directory

The question is:

Using C++ language to complete this homework

1. Develop class Polynomial. The internal representation of a
Polynomial is an array of terms. Each term contains a coefficient and
an exponent. The term

2x4
has the coefficient 2 and the exponent 4. Develop a complete class
containing proper constructor functions as well as set and get
functions. The class should also provide the following overloaded
operator capabilities:

(a) Overload the addition operator (+) to add two Polynomials.
(b) Overload the multiplication operator (*) to multiply two
Polynomials.
(c) Overload the subtraction assignment operator (-) to process two
Polynomials
(d) Overlaod the assignment operator to assign one polynomial to
another
(e) Overload the addition assignment operator (+=), subtraction
assignment operator (-=), and multiplication assignment operator(*=).

I'm going crazy here. Please help.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.l earn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library

Aug 12 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1878
by: Mojo | last post by:
Ok, I don't want to much help but I need a push. I am supposed to write a program with 3 classes: 1. Controlling class 2. Student class 3. Grades class Controlling class instantiates a student ( I need 5 of these) object and gives it a name and studentID. Then I need to create a Grades object that goes with the student that holds 5 grades. So far I have the Controller creating the student and then in the student
16
2623
by: Kirk Bevins | last post by:
Hello, new to posting, got a dilema in c++. I cant seem to create new instances of my student class. The idea is to make a database where the user inputs surnames and library card numbers etc. The piece of code I cant get to compile is: ......void main() { for (int i=0; i<10; i++) { student s;
6
2410
by: laj | last post by:
HI, Excuse this new question, I am trying to impress my wife by putting a db together for her dance studio. I put a table with all students new and old with fields including name and address and than a series of fields each is a yes/no for a given offered class. On the form you just check the class or classes they are enrolled in. My wife wants to be able to generate a list of students (non-active) who do not have any of the classes...
2
9701
by: sallyk07 | last post by:
Modify the Student class so that each student object should also contain the scores for three tests. Provide a constructor that sets all instance values based on parameter values. Overload the constructor such that each test score is assumed to initially be zero. Provide a method called setTestScore that accepts two parameters: the test number (1 through 3) and the score. Also provide a method called getTestScore that accepts the test number and...
4
2469
by: Dave White | last post by:
Hello Everyone, I have created two tables to track my students' lessons. Each student is responsible for most, but not all. of the lessons. I've tried a junction table but I can't figure out an easy way to assign one or multiple lessons to a student. tbl_Students
11
4063
by: xxbabysue123xx | last post by:
Heres the problem: Create a class Student with instance data name, studentNumber, class (where class is a String containing one of the following: “Freshman”, “Sophomore”, “Junior”, “Senior”. Make the class implement the Comparable interface. Include a toString method. Write a driver program to demonstrate your work. Instantiate several objects of the Student class. Call your methods several times to show that class is ordered. ...
3
2689
by: Synapse | last post by:
hi everyone..im trying to create a student list program using linked list that will display all my info of students..but it seems theres a little prob. after i enter my first student the program will exit.. can somebody help me please. thank you #include <stdlib.h> #include <iostream.h> #include <string.h> #include <conio.h> class student {
4
4092
by: withu4ever | last post by:
I learned how to use struct when I try to write a program i face some misstakes which I cant correct This is the program: ------------------------------------------------------- #include<stdio.h> #include<string.h> main() {int nu,i; /* nu is number of student */
1
1188
by: =?Utf-8?B?UGF0c3k=?= | last post by:
Hi I recently purchased my new laptop with Trial Version of Student & Home Office 07. Having activated it (following all the instructions) I cannot actually use it. I cannot input information of any of the programs provided message at bottom of screen says "This modification is not allowed because the selection is locked". How do I get out of this as I am desperate to use these programs in my training assignments - Help please Patsy
0
9591
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10594
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10343
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9166
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7631
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5667
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.