C# :: Delegate Wrong Return Type?

Feb 25, 2014

i'm getting a new error is a wrong return type.

WebAPI.cs
namespace DarkAPP___WForm.Libs {
class WebAPI {
System.Net.WebClient wc = new System.Net.WebClient();
public WebAPI() {

[code].....

View 6 Replies


ADVERTISEMENT

C++ :: Singleton Class - Auto Seems To Return Wrong Type

Jul 18, 2013

I am trying out a technique for a singleton class:

// access controlled singleton, accessed through function "instance()"
// singleton is constructed in this function
// so that constructor and destructor will be used
class single {
// private constructor/destructor

[Code] .....

Playing around with the code in main(), I am having trouble with auto:

single& s = single::instance(); // works fine
auto a = single::instance(); // error ~single() is private

When I make the destructor public, the output of the program is:

ctor
dtor
dtor

So I fixed this by typing auto&. I'm still confused though, why wouldn't auto know I am returning a reference?

View 2 Replies View Related

C++ :: Wrong Return Type When Returning Char Array As Pointer

Apr 25, 2014

I am writing a class Player which has several char arrays as private fields. I am trying to write a method which returns an array as a pointer, but doesn't alter the array in any way, thus the const.

Here is a snippet:

Code: class Player
{
private:
char state[MAX_STATE_CHAR + ONE_VALUE];
int rating;
char last[MAX_NAME_CHAR + ONE_VALUE];
char first[MAX_NAME_CHAR + ONE_VALUE];
int groupNumber = NEG_ONE;
public:
char * GetFirst() const
{
return first;
}

Visual studio is saying that the return type doesn't match.

View 3 Replies View Related

C++ :: Find Index Of String Array - Get Wrong Return Value?

Apr 17, 2014

Here is my code to find the index of a string array whose string is equal to the query string. I have checked the program can return the correct index, but the cout result is totally wrong.

#include <iostream>
#include <string>
using namespace std;

[Code].....

View 4 Replies View Related

C# :: Static And Delegate - Cannot Be Accessed With Instance Reference

Feb 25, 2014

I'm getting some errors while i try to make a program code in C#Net. Here is the part of code that are returning error and a printscreen...

public static void Func_Register(string function, Del func) {
funcs.Add(function, func);
return;
}

Image 1: [URL] ....

private void console_Load(object sender, EventArgs e) {
CAPI.SetRTB(cmd_text);
CAPI.Func_Register("Console.Test", test);
CAPI.Func_Register("APP.Exit", Application.Exit);

[Code] .....

Image 2: [URL] ....

The idea of the code is to make a console to parse some commands. And have some commands with arguments and others no. Without the static the program return other error that is...

Image 3: [URL] ....

View 9 Replies View Related

C++ :: Return Value For A Type Class?

Apr 25, 2014

Code:
returnType operatorOperatorSymbol (parameterList); // syntax for operator overloading
Class Fraction

public:
Fraction operator-(const Fraction& f1){
Fraction r;
return r;
}

Is this even syntactically correct? It gives me errors. Im just trying to compile it without errors. I think the function makes sense since its returning a type Class

View 2 Replies View Related

C :: Functions With Different Return Type?

Feb 26, 2015

understand the below program.

Why I'm getting output y is 6.000000

Code:
#include <stdio.h>
int square(double a);
int main()

[Code].....

View 6 Replies View Related

C++ :: Get Return Type Of Function

Nov 21, 2012

Say I have overloaded functions with different arguments AND return types. Each set of argument has only one corresponding return type.

Code:
Vector grad(Scalar)
Tensor grad(Vector)

Later I have:

Code:
template <class T>
void test(T x) {
... Y = grad(x)
}

Then how do I automatically declare the type of Y. Do I need to make the grad function a template and specialize each of them ?

View 4 Replies View Related

C++ :: Object Type Method Return

Apr 29, 2014

I am new to c++ and trying to learn. for instance. i have a struct and method.I am trying to learn what i can do with the method if i define the return type as struct type.

struct S {
int age;
string name;
};
S method() {
//what i can do in here. with the Struct. I mean can i reach members of the struct. etc
}

View 2 Replies View Related

C++ :: Return Type For Assignment Operator

Apr 7, 2014

I am wondering why return type for an assignment operator cant be a void or int? Cant I write assignment operator for student class like this as we do nothing with returned value?

Student {
char name[20];
int marks;
public:
student(char*name,int marks)

[code].....

View 2 Replies View Related

C/C++ :: Node Data Return Type?

Apr 7, 2014

In my main I have a do/while loop, which is to iterate around the method calculateImportance while i is not equal to the numNodes.

do
{
int i;
int numNodes = Test.count();
for(i=0; i<=numNodes; i++)

[Code]....

I have been messing around with the data type node, hence why it is there are present, but, that doesn't seem to the answer

This is the function declaration in the header file.

node CalculateImportance();

View 1 Replies View Related

C/C++ :: What Is The Default Return Type Of A Function

Jan 17, 2013

i heard that it was int but later it is deprecated , so at present what is the default return type of a function ?

View 4 Replies View Related

C/C++ :: Return From Incompatible Pointer Type

Jul 13, 2014

/*
* symboltable.c
*/

#include "symboltable.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "include/utlist.h"

[Code] ....

View 2 Replies View Related

C++ :: Setting Function Return Type

May 28, 2012

I want my function to return the type mpz_t, but I'm not sure how?

I've tried: mpz_t MyFunction(mpz_t A, mpz_t B){}

But it didn't work, here is my code so far, I have bolded the parts of the code which are causing errors and added the errors in the comments:

Code:
#include <iostream>
#include <mpir.h>
using namespace std;
???? A(mpz_t m, mpz_t n){
mpz_t mmo; //used to store the value of m, minus one

[Code] .....

Is there a way around this?

View 5 Replies View Related

C++ :: Returning A Structure As Function Return Type

Apr 4, 2013

I am having problems with my function definition of a function that should return a structure value.

This is the error I get compute.cpp(9): error C2146: syntax error : missing ';' before identifier 's_advertisebus'

The error is on the line where I start my function definition typing my function type as a structure. A long time ago in c the keyword struct is used with the structure type like struct s_advertisebus s_readadbus(). I tried it both ways but I got errors.

// struct.h
#ifndef STRUCT_H
#define STRUCT_H

struct s_advertisebus {
int nnumberofads;
float fpercentused;

[Code] ....

View 2 Replies View Related

C++ :: Using Pointers With Function Both As Arguments And Return Type

Jan 29, 2015

I always have confusions while using pointers with functions both as arguments and as return type.

View 1 Replies View Related

C/C++ :: Why To Use Return Type For String Function As Char

Oct 6, 2012

If we are using strcpy() for copying the string. As we are passing pointers to it It will copy the string & no need to return the string .This function will finely work with return type as void then why Ritchie has used it as char* strcpy()?

View 4 Replies View Related

C/C++ :: Get Return Type Of Function In Template Parameter

Jul 27, 2012

Is this really the preferred way to get the return type, for use in a derived class, of a function defined in the template parameter?

template<class PARAMETER> class C {
         protected:
            typedef typeof (reinterpret_cast<PARAMETER*>(0))->function() returntype;
      };  

This works just fine for me, but seems inelegant.

View 12 Replies View Related

C++ ::  Function Return Type Template Parameters Can't Be Deduced

Dec 9, 2013

I have this code:

#include <iostream>
#include <vector>
#include <map>
#include <string>
using namespace std;

[Code]...

and it does not compile.

The error is:

test.cpp: In function ‘int main()’:
test.cpp:20:30: error: no matching function for call to ‘func1(std::vector<int>&)’
test.cpp:20:30: note: candidate is:
test.cpp:8:45: note: template<class T, class U> std::map<T, T> func1(U)
test.cpp:8:45: note: template argument deduction/substitution failed:
test.cpp:20:30: note: couldn't deduce template parameter ‘T’

View 3 Replies View Related

C++ :: Template Method Based On The Type Passed Should Return A Value

Mar 8, 2014

I have a class where a method based on the type passed I should return a value.

prototype declared in the header file:

template <typename T>int getNum() const;

Code of the cpp file:

template <typename T> int class::getNum() const{
int c = 0;
for(int i=0;i<v.size();i++)
if(typeid(*(Pro*)v.at(i)) == typeid(T)) c++;
return c;
}

To invoke the method as I do:

ostream & operator << (ostream & os, Pro & obj) {
return os << obj.getNum();
}

View 4 Replies View Related

C Sharp :: Use Return Type Bool In WEB API Post Method?

Oct 3, 2012

I sew lot of sample for ASP WEB API. In althose link the post method is using

HttpResponseMessage as return tyope

Is it possible to use return type bool in WEB API post method?

View 1 Replies View Related

C++ :: Creating Flexible Interface For CL Application - Auto Return Type?

Nov 24, 2013

I am trying to create a flexible interface for my CL application. And what i have is this :

Code:
using namespace std;
// iplcp -i queryFile -d databaseFile
template <typename INT, typename CHARA>
class API {

vector<string> files;
vector<INT> flags;

[Code] ....

and in main :

int main(int argc, char **argv){
//set variables
API<int, char**>args(argc,argv);
cout << "In file: "<< args.GetOpt("i") << " Db file: " << args.GetOpt("h") << endl;
}

// first thing to be printed should be string and the second int

I know this is not probably the best way to but i am laying around and was curious if something like this could work . Are there any good C++ templates for CLI applications from which i could learn?

View 7 Replies View Related

C++ :: Delegate Class - Support Void Class Function With No Parameters

Jun 22, 2013

I'm trying to write a simple Delegate class with a Bind() and Invoke() function. For now it only needs to support a void class function with no parameters. I've searched around and found quite a few exmaples, though, those class are heavily templated and I lose track trying to simplify it.

So far my code is following:

Code:
#include <windows.h>
class Test {
public:
void DoSomething() {
MessageBox(NULL, L"Test::DoSomething!", NULL, 0);

[Code] ....

The part I am having difficulty with is assigning &Test::DoSomething to the m_Callback variable.

&tObject::DoSomething works, yet _Callback which I pass &Test::DoSomething to does not work.

Also, why does the following line work:

Code:
m_Callback = &Wrapper<tObject, &tObject::DoSomething>;

When wrapper is like:

Code:
template<class tObject, void (tObject::*Func)()>
void Wrapper(void* Object)

Should it not be Wrapper<class-typename, parameter-1>(parameter-2) // This currently creates an error

View 2 Replies View Related

C :: Will Return Root Statement At End Ever Return Value Other Than Value Passed To Function?

Mar 29, 2013

I'm writing some functions pertaining to binary trees. I've used recursion once before while learning quicksort but am still quite new and unfamiliar with it. And this is my first time touching a binary tree. So my question: In my addnode function, will the return root statement at the end ever return a value other than the value passed to the function?

Code:

#include <stdlib.h>
struct tnode
{
int data;
struct tnode * left;
struct tnode * right;
}

[code]....

View 4 Replies View Related

C++ :: Return By Reference - Statement Doesn't Return Value Of N

Jan 11, 2015

From the page: [URL] ....

#include <iostream>
using namespace std;
int n;
int& test();

[Code] ....

Explanation

In program above, the return type of function test() is int&. Hence this function returns by reference. The return statement is return n; but unlike return by value. This statement doesn't return value of n, instead it returns variable n itself.

Then the variable n is assigned to the left side of code test() = 5; and value of n is displayed.

I don't quite understand the bold sentence. Shouldn't value of n and variable n be the same?

View 8 Replies View Related

C++ :: Variable Assigned Wrong Value?

Nov 15, 2012

Consider the following:

Code:
float foo( float const *bar )
)
{
float temp;
temp = *bar;
...
}

Something I am noticing is that temp right after the assignment to *bar, is not the same value as *bar. This is for a project at work and the code runs on an embedded board with an ARM processor. I've copied the function into a standalone program for both Visual Studio and Code::Blocks and it works correctly there.

View 12 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved