C++ :: Pow - No Overloaded Function Takes 1 Arguments
Oct 4, 2013
I keep getting this error in my code. I believe it is because to use pow(x,y) both x and y have to be double, but how do i put that into my formula under calculations?
#include <iostream>
#include <cmath>
#include <iomanip>
#include <string>
#include <fstream>
using namespace std;
int main() {
// Declaration section: Declaring all variables.
[Code] ....
View 4 Replies
ADVERTISEMENT
Apr 20, 2014
Write a function that takes two input arguments and provides two separate results to the caller, one that is the result of multiplying the two arguments, the other the result of adding them.Since you can directly return only one value from a function, you'll need the second value to be returned through a pointer or reference parameter.
Code:
#include "Code.h"
#include <iostream>
#include <string>
double x, y;
[Code] ....
View 3 Replies
View Related
Dec 7, 2012
How do I Write a function that takes two linked list as input arguments these linked list contain numbers like this:
num1->3->5->2->NULL (assuming that number 1 is 352)
num2->4->3->9->1->NULL (assuming that number 2 is 4391)
The function should return 1 if num1 points to a linked list which represents a smaller number than the number pointed to by num2 linked list. Otherwise, it returns -1. If both linked list point to exactly the same number, returns a 0.
View 3 Replies
View Related
Feb 10, 2014
I am having trouble creating a new User from my User Class. The error I am recieving:
Error3'HospitalSystemBL.User' does not contain a constructor that takes 2 argumentsC:UsersStudentdocumentsvisual studio 2010ProjectsHospitalSystemHospitalSystemLogin.aspx.cs2131HospitalSystem
In my User class, I have two constructors. Default and an overloaded constructor.
//default constructor
public User() {
}
//overloaded
public User(long UserName, string Password)
[Code] ....
I am trying to create my user in my Login class. Why is the error saying "does not contain a constructor that takes 2 arguments" when I have a constructor (above), User passing two arguments: UserName and Password? Here is my code for the login:
protected void btnLogin_Click(object sender, EventArgs e) {
try {
int Userid = Convert.ToInt32(txtUser.Text);
string password = txtPassword.Text;
[Code] ....
View 11 Replies
View Related
Jan 18, 2015
I'm just getting back into the swing of things after a long time of not programming. I'm trying to create a program which takes in command line arguments and prints the last one. My code is as follows:
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main() {
string x;
vector<string> arguments;
[Code]...
And the error message I receive, a simple but frustrating one, is as follows:
Enter arguments, enter STOP to stop: Segmentation fault...
View 1 Replies
View Related
Nov 10, 2014
Here is a sample of my question
class Base{
public:
int getNum();
private:
int numToGet;
}
class Derived: public Base {
public:
friend ostream& operator<<(ostream& output, const Derived &B);
[Code]...
View 1 Replies
View Related
Apr 3, 2013
why can't << operator be overloaded as a member function is it because that is the way c++ is written and you just can't or is there another reason because I'm confused.
View 2 Replies
View Related
Sep 17, 2013
I don't exactly know how to test my ==friend function in my main.
Here is my .h file:
#include<iostream>
using namespace std;
class Car{
public:
Car();
Car(int yer, string mke);
[Code] ....
View 3 Replies
View Related
Oct 23, 2014
I need to return taxes paid and net pay by pass referencing a gross pay overloaded function. Are the values returned from calling the overloaded function file stream objects? Can they be passed simply through a pass-by-reference function?
//Read Data from File, gather info and calculate pay, output data to file
while(counter < x) {
inFile >> last_name >> first_name >> hours_worked >> hourly_pay;
outFile << first_name << " " << last_name << " ";
outFile << calculate_gross_pay(hours_worked,hourly_pay);
counter++;
outFile<<endl;
[code].....
View 8 Replies
View Related
Feb 11, 2015
#include<iostream>
using namespace std;
#include<string>
main() {
cout<< "donner votre nom:";endl;
string nom("sans nom");
cin>> nom;endl;
cout<< "votre nom est:"<<nom; endl;
return 0;
}
when i try to build this program, i get this masseges:
in function 'int main()':
statement cannot resolve address of overloaded function
this a picture of the errors:
View 6 Replies
View Related
Jan 7, 2014
Write a c++ function that takes int as an argument and doubles it.the function does not return a value.
View 5 Replies
View Related
Nov 2, 2013
I can't seem to figure out whats causing this error: statement cannot resolve address of overloaded function . Error is before line 14 in bubblesortrand function. Thnx in advance.
void bubblesort(int num[], int a_size)
{
int i, j, temp;
for(i = (a_size - 1); i >= 0; i--)
[Code].....
View 4 Replies
View Related
Aug 5, 2013
The question involves me writing a program using a overloaded function to calculate the Weekly rate of employees but they get paid hourly and weekly. I get this error but do not know why,
#include <iostream>
using namespace std;
int calcWeeklyPay(int paidWeekly, int annualSalaryWeekly)
//Returns the Weekly salary of weekly paid Employees
int calcWeeklyPay(int paidHourly, int annualSalaryHourly)
//Returns the Weekly salary of Hourly paid Employees
[Code]...
View 3 Replies
View Related
Feb 23, 2015
I just want to call the function : outputboo(), but I dont know how
Code: /*Enthusiastic
Pessimism
desensitize
uniqueness
*/
#include <stdio.h>
#include <string.h>
struct Books{
char title[50];
char author[50];
[Code]...
View 2 Replies
View Related
Dec 7, 2013
Write a c function which takes a string(as a character array, null terminated) and reverses it. it doesn't print the reversed string -- it modifies the given string so that it is reversed.
Code:
void reverse(char array[]) {
char tmp;
int i, j;
for(i=0;i<strlen(array); i++){
for(j=strlen(array)-1;j>=0;j--) {
tmp = array[i];
array[i] = array[j];
array[j] = tmp;
} } }
how come this doesn't work?
View 2 Replies
View Related
Nov 25, 2014
I have to make a program that takes several numbers into an array into a function, and send them back into the main function multiplied by 1.13. This is what I have so far:
#include <iostream>
using namespace std;
void connell(int&n[20])
main() {
int num[20];
[Code] ...
I do not know how to get numbers from an array from a main program to a function.
View 2 Replies
View Related
Feb 2, 2013
I'm stuck on the last part of my program. The directions are the following~
Expand the program to add an overloaded function to handle floating point numbers (i.e., doubles). Include output for one list of integers and one list of doubles. Use this function prototype: double avgx(double&, double&, int, ...);
Compile and run. You should have one function named avg, one named davg, and two functions named avgx
My code does not compile and I think I'm not declaring my function prototype correctly?
#include <iostream>
using std::cout;
using std::endl;
#include <cstdarg>
// function prototype(s)
int avg(int, ...);
[Code] ....
View 2 Replies
View Related
Jun 11, 2013
I have a class matrixType that has some overloaded operators (+, -, *, and <<). With a view to having clearly-delineated, perfectly-formatted, four-sided matrices, as shown below:
A = 1 2 3
4 5 6
7 8 9
or
A + B = 1 2 3
4 5 6
7 8 9
and NOT this jagged ones shown below:
A = 1 2 3
4 5 6
7 8 9
or
A + B = 1 2 3
4 5 6
7 8 9
,
I want a scheme in which the string literals (A, A+B, etc.) could be passed as parameters to the overloaded stream insertion (<<) operator function so that I could use the string’s length to determine how much offset from the display screen’s left to apply to each matrix’s row (by using the setw() function). However, I do know that the << operator is a binary operator, meaning the function cannot take more than two parameters: that is what compounds my problem!
View 10 Replies
View Related
Mar 12, 2014
I am so close to finishing this program. It will find the median of an array of 5 values. I have one last error that I cannot seem to get to go away. Here's the code:
#include <algorithm>
#include <functional>
#include <array>
#include <iostream>
using namespace std;
int main() {
int integer1, integer2, integer3, integer4, integer5;
[Code] .....
The error states: "IntelliSense: no instance of overloaded function "std::nth_element" matches the argument list, argument types are: (std::_Array_iterator, std::_Array_iterator, unsigned int, std::_Array_iterator)
View 1 Replies
View Related
Sep 2, 2014
We have to write a function named fibonacci that takes an int indicating the length of the series and then store it in an array of size 20 printing the sequence from largest to smallest. Here is the small bit i have so far:
#include <iostream>
#include <iomanip>
using namespace std;
void Fibonacci( int );
int main( ) {
[Code] ....
I just need something to get me on the right track.
View 1 Replies
View Related
Feb 21, 2013
I have a school project in which need to create a function that takes a File Object as a Reference Parameter. Supposedly, it should allow me to read the first piece of data from others separated by a space from a file. The later be able to continue reading from the next piece of data.
I know how to set things up to read from the data file, such as using
Code:
#include <iostream> , and
Code:
ifstream inputFileName;
inputFile.open ("nameOfFile");
I also understand how to pass a variable by reference to a function. But I simply cannot put the two items together!
I tried using
Code:
void getFileInput (ifstream &); //parameter
getFileInput ("nameOfFile") // call
void getFileInput (ifstream &dataFileName)
In the function I used
Code:
ifstream inputFile;
inputFile.open (dataFileName);
I'm just not getting an understanding of this concept!
View 4 Replies
View Related
Jan 24, 2012
Hey I am trying to use the getline() function to read a line from a file. For some reason Visual Studio 2010 gives me the following error. "No instance of overloaded function "getline" matches the argument list". The piece of code that produces the error is in a class in a separate .h file and is executed as a method of the object. I'm almost certain it has something to do with either the compiler thinking I am calling another getline in a different namespace or my parameters for the function are incorrect. Here is the code:
Code:
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
using namespace std;
class InsultGenerator
[Code] .....
View 1 Replies
View Related
Oct 10, 2013
I was required to write a program that takes a baseball players statistics and displays there averages. I was required to make 3 function in the file to perform this tasks. my problem I am having a division problem in the SLG function. My compiler does not require the system ("PAUSE"); command.
OUTPUT
The player's batting average is: 0.347
The player's on-base percentage is: 0.375
The player's slugging percentage is:
(test)AB = 101
(test)Tot Base = 58
0.000
Code:
/* Batting Average Program
file: batavg1CPP.cpp
Glossary of abbreviations:
BA = batting average
PA = plate appearances
H = hits
BB = bases on balls (walks)
[Code] ....
View 3 Replies
View Related
Apr 27, 2013
I am doing a problem where I need to use arrays of string objects that hold 5 student names, an array of one character to hold the five students' letter grades and five arrays of doubles to hold each student's set of test scores and average score.
When I try to run it, I get these five errors.
error C2660: 'getTestScore' : function does not take 3 arguments : line 39
error C2660: 'getTestScore' : function does not take 3 arguments : line 45
error C2660: 'getTestScore' : function does not take 3 arguments : line 51
error C2660: 'getTestScore' : function does not take 3 arguments : line 57
error C2660: 'getTestScore' : function does not take 3 arguments : line 63
what is wrong.
Here's my code.
View 4 Replies
View Related
Feb 23, 2014
I get the following error in XCode whenever I try to access the member I created 'randomGen' in a separate class in a different header file. I have made sure to include the header file and have tried to access it through an object.
This is the code I enter when trying to access the method from randomiser.h in main.cpp. It is also an overloaded function with doubles and integers:
RandomG randomiser;
randomiser.randomGen(); // 'Call to member function 'randomGen' is ambiguous'
This is the code inside randomiser.h:
#include <string>
#include <iostream>
using std::string;
using std::cout;
using std::endl;
class RandomG {
[Code] ....
This is the error inside xcode: [URL] ....
I have tried seperating the code for the functions in another class (main.cpp) and then running and it seems to works, so I'm not sure why I can't put everything in the .h file and then access it?
I would like it in a seperate file so it doesn't clutter my main. I am writing a game with SDL so that might be confusing and I would like the window to have a random title and other random properties, so it would be easier to use a function.
View 3 Replies
View Related
Jun 5, 2013
I am a bit confused about how specific one must be with arguments when declaring a function. I'll show you two functions from the book I'm using to learn C to show you what I mean.
Example 1 (greatest common denominator function):
Code:
void gcd (int u, int v) {
int temp;
printf ( "
[Code] ....
So in that function, there are exactly two arguments, because that's how many arguments the algorithm to find the gcd takes. No problem there, makes sense to me. Then further in the chapter on functions I run into this,
Example 2 (square root function):
Code:
float absoluteValue (float x) {
if ( x < 0 )
x = -x;
return x;
[Code] ....
In this second example, we have a square root function that is preceded by an absolute value function. The absolute value function has the one argument, "float x", however when this function is called within the square root function, the arguments "guess * guess * -x" are passed to it. I'm confused how this absolute value function is working with all of that inside it, when it was originally declared with just "x." The only possibility I can think of is that this expression is treated as a single unit, but I'm not sure.
View 2 Replies
View Related