C++ :: Displaying Function From Reference?
Aug 29, 2013
Having a little trouble getting my function to display the results. I got my getNumber function working and I know I can't use return to return multiple values so I created a function that would display my results but I am a little lost on how I get the results from one function to another.
#include <iostream>
#include <array>
#include <iomanip>
using namespace std;
void printResult(int, int);
void getNumber(int &, int &);
void printResults (int, int){
int n, n1;
[code].....
View 13 Replies
ADVERTISEMENT
Feb 9, 2013
I am trying to display a variable from a class function the code works in debug but the variable is not displayed. Here is my code so far.
#include <iostream>
#include <string>
using namespace std;
class dayType {
public:
string day;
void setday(string);
[Code] .....
View 2 Replies
View Related
May 19, 2014
I have a module that pings the network to find available devices using threading.
the money line:
var valids = range.AsParallel().AsOrdered().Where(ip => ip.Ping()).ToList();
The problem is, I need to display a progress bar while this function runs. I have the progress bar implemented with a background worker, but it won't update while the ping module is executing. I *think* it's because I'm using the available threads for the ping module.
When the user clicks a button, I need the ping module to run while the progress bar updates, or even just set IsIndeterminite to true. What would be the best way to accomplish this?
View 4 Replies
View Related
Jul 1, 2013
Ok, so the assignment is to use a recursive function to display a request for a certain position in the Fibonacci Sequence (0, 1, 1, 2, 3, 5, 8, 13...)
The program I have written works, but it displays the wrong number in sequence. The book says that when you enter "8" you should receive "13", which is correct in the order of the sequence, though my program is producing "21" which is the next number in the sequence.
I tested it with a few more numbers and when I enter "7" it produces "13" and when I enter "6" it produces "8" and so on.
Code:
//Cameron Taylor
#include <stdio.h>
int main(){
[Code].....
View 2 Replies
View Related
Jan 19, 2013
The error is this:
#include <iostream>
using namespace std;
void add(int s);
void subtract(int d);
void multiply(int p);
void divide(int q);
[Code] .....
View 2 Replies
View Related
Nov 23, 2013
I'm making a program that's essentially a Text-Based Fire Emblem game; it runs calculations and rolls dice and has all sorts of Goodies. However, I have hit a block to the tune of
#ifndef ITEM_H
#define ITEM_H
class Item
{
[Code]....
Up Until I called up a Sword object, it worked fine. But when I compiled it, I got an Undefined Reference to Item::Item() error in Line 8 of Weapon.cpp.
View 2 Replies
View Related
Feb 15, 2015
#include<iostream>
using namespace std;
int &fun() {
int x = 10;
return x;
}
int main() {
fun() = 30;
cout << fun();
return 0;
}
The code outputs 10.
Shouldn't it show an error because x is created locally on stack and gets destroyed on function return?
View 1 Replies
View Related
Oct 2, 2014
Everything seems to be in order and I know my code still has mistakes. I'm just trying to get it to compile and it won't allow it. I've narrowed it down to when I call the functions in main but beyond that I have no clue.
#include <iostream>
#include <cstring>
using namespace std;
void getSize(int num);
void getSpace(int num, int ptr);
void inputData();
void printData();
void destroy();
const int BIG_NUMBER = 100;
[code]....
View 4 Replies
View Related
Oct 24, 2013
So I have a really strange problem occurring...
First, here are the files I'm using:
//pa4.cpp wirtten by Syd Frederick
#include<iostream>
#include<string>
#include<fstream>
[Code].....
When compiling I'm getting a strange error that says :
/tmp/ccdt0Bf9.o: In function `main':
pa4.cpp:(.text+0x1c): undefined reference to `synopsis()'
pa4.cpp:(.text+0x1e7): undefined reference to `execute(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
collect2: ld returned 1 exit status
View 2 Replies
View Related
Mar 26, 2013
The following function uses reference variables as parameters. Rewrite the function so it uses pointers instead of reference variables, and then demonstrate the function in a complete program.
int doSomething(int &x, int &y)
{
int temp =x;
x = y * 10;
y = temp * 10;
return x + y;
}
I understand how to covert the reference variables to pointers, however I am stuck on this error. Either I get the error listed in the title or (with a few changes) the error "invalid conversion from 'int' to 'int*'"
What am I doing incorrectly?
#include <iostream>
using namespace std;
int doSomething(int*, int*);
int main(){
int X, Y, result;
[Code] ....
I have multiplied both x and y by 10 and then added them together!
Here is the result " //I really didn't know how else to use the "doSomething" function in a meaningful way. So... I just stated what the function does.
<< result << ".
";
system("PAUSE");
return 0;
}
int doSomthing(int *x, int *y)
[Code] .....
View 1 Replies
View Related
Feb 20, 2015
Been away from c++ for a few months now (apart from answering a few questions on this site). I was trying to see if I could do a simple program using just my memory that involved unique_ptr's, but getting an error:
"attempting to reference a deleted function". I thought that by getting a reference to my pointer would not invoke a copy constructor but i'm clearly wrong.
Here's the code:
#include <iostream>
#include <memory>
#include <vector>
class Shape {
public:
virtual void Draw() = 0;
[Code] ....
View 5 Replies
View Related
Feb 22, 2015
So I was reading my book and it listed this piece of code. The first piece of code is in the book and the 2nd is just my test on the piece of code. I am curious as to why in the functions parameters there is a reference to aString. I've noticed that removing it has no affect on the outcome of the code.
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
bool isPalindrome (string & aString) {
[Code] ....
View 2 Replies
View Related
Oct 21, 2013
I am coding a RTS game but I cant compile my dataLoader function. It gives that errors when want to call it:
//Window size
int width;
int height;
if( !dataLoader<int>( width, "settings/resolution.txt", "width" ) || !dataLoader<int>( height, "settings/resolution.txt", "height" ) )
[Code] ....
View 7 Replies
View Related
Sep 28, 2014
I am going to read some codes about image processing and I need to understand functions like this one below?
BOOL Trans_Geo_Affine(CImage *pImgSrc, CImage *pImgDst, BOOL bMatrix,
BOOL bHvInversed, double fScale_xx, double fFlex_xy, double fSkew_yx,
double fRotate_yy, double fTx, double fTy, int nInterpolation, BOOL bResize, BYTE cFill)
[URL]
two parameters, CImage *pImgSrc and CImage *pImgDst. I think they are class pointers and the function is passed by reference. What should I learn to understand this function and its parameters? How should I use this function? how to use the function with two parameters CImage *pImgSrc and CImage *pImgDst.
View 11 Replies
View Related
Jun 3, 2014
I dont know what kind of return reference I have to put to override the following derived member function in C++:
virtual SEntityPhysicalizeParams& GetPhysicsParams() override {return ???;}
The place where I should put the return value is marked with ???. SEntityPhysicalizeParams is a struct from another header from which I dont have access to it's source file.
I tried several things but noone seemed to work out and keep getting me either error "function must return a value" or "initial value of reference to non-const must be an lValue".
Here is SEntityPhysicalize where my function is refering to:
struct SEntityPhysicalizeParams
{///////////////////////////////////////////////////////////////////
SEntityPhysicalizeParams() : type(0),density(-1),mass(-1),nSlot(-1),nFlagsOR(0),nFlagsAND(UINT_MAX),
pAttachToEntity(NULL),nAttachToPart(-1),fStiffnessScale(0), bCopyJointVelocities(false),
pParticle(NULL),pBuoyancy(NULL),pPlayerDimensions(NULL),pPlayerDynamics(NULL),
pCar(NULL),pAreaDef(NULL),nLod(0),szPropsOverride(0) {};
[Code] ....
View 8 Replies
View Related
Nov 19, 2013
I am currently working on a code, but I keep getting a error as follows:
[Linker error] undefined reference to 'getHoursOfTheWeek(double)'
[Linker error] undefined reference to 'getGrossPay(double)'
[Linker error] undefined reference to 'getStateTax(double)'
[Linker error] undefined reference to 'getFederalTax(double)'
[Linker error] undefined reference to 'getFICA(double)'
[Linker error] undefined reference to 'getWithHoldingAmount(double)'
I have been trying to debug this error for hours and I am completely stumped....
//BEGIN
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
string getUserName();
double getPayRate();
[Code] .....
View 2 Replies
View Related
Mar 4, 2013
If f1 and f2 are two user defined functions.
main(){
int *p;
f1(&p)
}
f1(**p){
f2(&p);//
If I've to pass the pointer by reference again in another function, will I've to do something like this?
}
f2(***p){
**p = NULL;
}
View 3 Replies
View Related
Nov 28, 2013
I have a class called Point that has functions for getting and setting x, y, and z coords., distance, and midpoint. I need to write a function that prints the class and must use ostream & displayPoint( ostream & ); as the prototype. I did some googling and came up with
std::ostream& Point::displayPoint(std::ostream& out)
{
out << "(" << out.getx() << ", " << out.gety() << ", " << out.getz();
return out;
}
in order to print (x, y, z).
My IDE (Xcode) says "No member named 'getx' in std::__1::basic_ostream<char>"
I don't understand much about ostream reference
View 1 Replies
View Related
Mar 16, 2015
I'm getting an undefined reference error to a function, and I can't figure out why. I have tried letting code blocks compile the files, I have tried the command line to compile it with the same results.
I looked up the error and found this from [URL]
undefined reference
Example
/tmp/cc2Q0kRa.o: In function `main':
/tmp/cc2Q0kRa.o(.text+0x18): undefined reference to `Print(int)'
collect2: ld returned 1 exit status
Meaning / Your code called the function Print, but the linker could not find the code for it in any .o file
Usual Causes
You forgot to link the .o file that contains the function
You misspelled the name of the function
You spelled the name of the function correctly, but the parameter list is different in someway
which seems to be the error I get. I have double checked all 4 and I see nothing.
The code that specifically gives me the error is:
Item *name = new Item(desc, id, weight, loc);
itemMap.addItem(name);
and the class looks like this:
class Item // Standard Items {
private:
std::string name;
std::string desc;
int id;
int weight;
int loc;
[code].....
I think everything matches up unless I'm just missing it.
Full codes are located here: [URL]
what I'm doing wrong?
View 5 Replies
View Related
Sep 25, 2012
I created the following code to pass the the variable 'inputVoltage' by reference to the function 'input'. It certainly works when I run the program, but I dont think it is a standard way of doing it, i.e. the use of '*' and '&' is not according to convention ? Or perhaps the way did it is acceptable ?
int input (double *inputVoltage);
int main ( {
double inputVoltage;
input(&inputVoltage);
[Code]....
View 2 Replies
View Related
May 14, 2012
struct emp {
char name[20];
int age;
float sal;
}e1 = {"hello", 24, 2345.67}, e2 = {"hi", 34, 45678.89};
[Code] ....
Query: I am unable to get emp &fun() and fun() = e2...
View 3 Replies
View Related
Feb 27, 2013
So on lines 36 - 39 (The commented out functions) is where I'm sure is causing this error because once I don't comment them out pretty much everywhere Flink or Rlink is used or defined I get this error.
#ifndef nodes_Nodes_h
#define nodes_Nodes_h
#include <cstdlib>
[Code]....
View 4 Replies
View Related
Dec 8, 2014
I have to write an example in which you use a function having as argument a pointer passed by reference in C++. Can you provide an example like this:
funz.h : void funz( int *&a );
funz.cpp : ? (1)
main.cpp:
#include "funz.h"
#include <iostream>
[Code]...
as I write in (1) and (2) ?
View 5 Replies
View Related
Sep 19, 2014
Due to the nature of this requirement, I've made a very minimal example, which would adequately solve my issue, without resorting to use of pointers or copy constructors.
Basically I'm trying to pass an object as a reference to the template function, rather than a copy as it's seeing. I'm needing to do this without editing Obj::Call to accommodate a reference as its first parameter, as it'd break other calls.
You'll notice in the following code the object will be destroyed upon passing, while the object defined is still in-scope due to the infinite end loop.
#include <iostream>
#include <string>
using namespace std;
class Obj {
public:
string name;
[Code] ....
In the past I tried ref(), which appeared to stop this happening, however it created a blank copy of the object instead.
View 1 Replies
View Related
Oct 4, 2013
I don't understand how my code not run.
#include "stdafx.h"
#include<iostream>
using namespace std;
struct student{
char name[30];
char birthday[20];
char homeness[50];
float math;
[Code] ....
View 3 Replies
View Related
Oct 12, 2014
Okay, so for an assignment I need to write a function called find() that returns a reference to a vector. So I have vector <int> & find(string & key); If I do this, I get the obvious warning warning: reference to local variable 'lineNum' returned [enabled by default].
If I do vector<int> & find(string & key) const; I get a huge error that starts out like
In member function 'std::vector<int>& index_table::find(std::string&) const':
indextable.cpp:74:30: error: no match for 'operator='
Am I using the const identifier incorrectly?
View 5 Replies
View Related