C# :: Calling Same Method Twice With Different Output

Dec 24, 2014

Allow users to enter their name and favorite saying in a single method that gets invoked two times. If I can only return one value at a time, how am I suppose to get name and favorite saying out of UserInput()?

static void Main(string[] args) {
string displayName, favoriteSaying;
DisplayInstructions();
Console.WriteLine();//readability

[Code] ....

View 3 Replies


ADVERTISEMENT

C++ :: Map Container - Calling Overloaded Virtual Method

Oct 7, 2013

Im trying to create a map container with the key being an ID number and the value being a pointer to a class object. Currently Im creating objects and storing their address in the container. I am getting a runtime error when calling the virtual method with this pointer. I believe that the problem is being called because they aren't being called pointer/reference. let me know if you need more.

if(command == 'F'){
inputDataFile>>name>>mNumber>>email>>department>>tenure;
faculty newFaculty(name,mNumber,email,department,tenure);
person* facultyAdd = &newFaculty;
cout<<"Note: Adding "<<mNumber<<"..."<<endl<<"Adding ";
people.insert(pair<string,person*>(mNumber,facultyAdd));

[Code]...

View 3 Replies View Related

C++ :: Copy Assignment Operator Method Calling?

Nov 12, 2014

how the operator overloaded methods called in C++?

Class String {
int len;
char *str;
public:
String(const char *str1="") {
len=strlen(str1);
str=new char[len+1];
strncpy(str,str1,len+1);

[code]....

View 1 Replies View Related

C++ :: Segmentation Fault When Calling Factory Class Method

Mar 23, 2014

I'm still working on my process API, as in my previous posts. Right now I'm trying get my class portable so I can use it for any language/compiler by using a factory design pattern. I'm having problems figuring out how to call the methods properly from my interface pointer in my factory class without causing a segmentation fault.

Code: main.cpp
Code: #include "exports.h"
#include <iostream>
using namespace std;

[Code]......

View 5 Replies View Related

C++ :: Using Static Method To Check Arguments Before Calling Constructor?

Mar 1, 2013

I would like to avoid throwing things in constructors as much as possible.

Is this good design to have a static class method that checks arguments the caller will give to the constructor. The documentation of the class will say, thou shall call this method to validate thine arguments before calling the constructor, or else segfault may befall thoust.

View 14 Replies View Related

Visual C++ :: Calling ATL COM DLL Method (that Opens A Dialog) From Browser?

Oct 11, 2013

I have a COM Object created using ATL (without MFC Support)

The Object has 1 method that opens a Dialog (that does all the rest) and when finish - returns 2 values back (1 is enough)

Currently I call it from another EXE:

hr = CoCreateInstance(
CLSID_MyControl,
NULL,
CLSCTX_INPROC_SERVER,
IID_IMyControl,
(void**) &pMyControl
);

and then:

hr = pMyControl->MyMethod (ATL::CComBSTR(InputString1), ATL::CComBSTR(InputString2), &IntReturned, &IntReturned);

Is it possible to call it as is from a browser ?

How can I Instantiate the object and invoke my method (with params) from the browser ?

will it open the dialog ?

View 3 Replies View Related

C++ :: Calling Method Of Specialized Template Base Class In Subclass

Feb 10, 2013

class IFoo {
virtual void Bar() = 0;
};

class FooAbstract {
virtual void Bar() {}

[Code] .....

How to call the Bar() method from FooTemplate in FooDerived::Bar()?

View 5 Replies View Related

C# :: Calling Method In One Form From Another Form?

Dec 6, 2014

I have a program which when a button is clicked on Form1 it runs a vision system operation on an image in a window on a Form1. There are also other buttons on the Form1 which can change things like threshold levels so the inspection can be run again with different settings. It all works fine but I want to change it to remove the buttons from Form1 so that when the user clicks on a button on Form1 it opens up another form, Form2, and all the buttons which were on Form1 are now on Form2 and the image analysis should run on Form1 when the buttons are used on Form2. I have taken over all the code from Form1 to Form2 and I'm trying to make this happen by creating a new oject on Form1 which calls a method on Form2 which contains the code which was in Form1 and called when the button was clicked on Form1 - not working!! I have a constructor in Form2 but I think I have become monumentally confused.

This was the code which was on Form1 when the inspection button was clicked.

private void cmdInspectOnce_Click(object sender, EventArgs e)
{
iReturn = VisionSystem.InvModeSet(IpeEngCtrlLib.I_MODE.I_EXE_MODE_ONCE);
if (_imgEngines!=null && _imgEngines[0]!=null)
_imgEngines[0].cmdInspectOnce();//InvModeSet(IpeEngCtrlLib.I_MODE.I_EXE_MODE_ONCE);
}

View 1 Replies View Related

C++ :: Undefined Reference To (method Name) When Accessing Method In Static Library

Jan 17, 2013

I've been trying for more than one month to access a method found in a library called libcocosnas_static.a. I'm using Cocos2d-X version 2.0.4. The library has been used many times by my company to make games using cocos2d-1.0.1-x-0.12.0 without any problem.

This is what I've done:
1- I added the include paths of the library to both eclipse and Android.mk
2- Included the .h file using #include "NASPlatformUtil.h"
3- Added the libcocosnas_static.a file to the proj.androidobjlocalarmeabi folder
4- Added "LOCAL_WHOLE_STATIC_LIBRARIES += cocosnas_static" to the Android.mk file
5- Called the function using: NASPlatformUtil:: openUrl("http://xxx.xxx.com/");

I can right click on the function, click Open Declaration and get it without any problem, but the compiler keeps on giving me that dreaded error...

View 3 Replies View Related

C++ :: Pass Method Of Derived Class As Parameter To Another Method In Base Class?

Feb 2, 2015

I have a question similar to the one here: [URL] .....

The main difference is I would like to pass a method of derived class as a parameter to some other method in its template base class.

template <typename BaseType>
class Base {
public:
typedef void (Base::*Callback)(int A);

[Code] .....

The above is an example which does not compile. My compiler complains that the two BaseMethod() calls in DerivedMethod() are invalid uses of non-static member function.

Is this not possible to do, or is my syntax simply wrong? All I want is to be able to pass as an an argument to a method in the base class from the derived class some callback as a variable for the base class to invoke later.

View 2 Replies View Related

C++ :: Method To Loop Through Network IPs

Nov 25, 2013

This problem relates to a program i am developing to ping all hosts on a network.

So far I've managed to access a PostgreSQL database to retrieve a CIDR network address e.g. 192.168.52.14/24.

I have then managed to mask the bits to get the network address.
So for e.g. above its 192.168.52.0

I now need some kind of algorithm to loop through available hosts so from.

192.168.52.0 - 192.168.52.255

I have got as far as deriving the network and separating it into an int array

So I have : ip_start[]= {192,168,52,0}

View 1 Replies View Related

C++ :: Using Reference With Virtual Method

Mar 19, 2013

#include <iostream>
using namespace std;
struct A {
virtual void f() { cout<<"A
"; }
};

[code]...

I would expect that both examples 2 & 3 will give me the same result.I tried to figure it out but I could not. Both are references of a base class type, that get a derived object.

Q1 : why is the difference between them ?

As I see it, its kind of a mix between pointer - which in case of virtual method that was override in derived class - would give me the derived method (e.g. "B") and between regular object - which in case of virtual method that was override - would give me the specific method (Still "B"). So, example 2 "use" it as a regular object and example 3, "use" it as pointer.

Q2 : How should I refer to it ? I am using VS2008.

View 12 Replies View Related

C++ ::  Inheritance Using Base Method With Other Name?

Feb 18, 2015

I have 2 classes with a Function with the same definition (both inherited from the same base class) and in my derived class I derive from both of those 2. Is it possible to use the Methods of both classes? for example with an other name?

class A {
protected:
int print(int a) { std::cout << "int A: " << a << std::endl; }
};
class B : A

[Code] ....

is there something like using C::print as printc;?

The Problem, I have a Sprite class that derives from a Rectangle with properties Position, Size, Origin and Angle and a Text class that derives from Rectangle. Now i have a Button class deriving from both Sprite and Text.

- The Position, when moving the Button i have to change the position of both so i Implemented a new Method which calls SetPosition from the Sprite and the Text.
- The SetSize just affects the Button so i just did using Sprite::SetSize;
- The angle affects both so i just implemented a new Method and hide the other two

The problem is here:
- The Origin: writing button.SetOrigin(-1,0) should set the Origin of the Button and writing button.SetTextOrigin should set the Origin of the text.

Should i just reimplement a Mehtod named SetTextOrigin and call Text::SetOrigin from there and hide the button.Text::SetOrigin or is there something like using Text::SetOrigin as SetTextOrigin?

View 6 Replies View Related

C++ :: How To Declare Empty Method

Oct 11, 2013

It has been a few years since I have had to do this, but I need to declare a method in my base class, but produce no code for it. Then when this library is used by my second project I will derive a class from this base class and put the code into it there. How is this possible? I used to know how but do not remember how now.

The library is a static library designed for linking with both 32bit and 64bit Windows applications to handle a lot of the tedious stuff with Windows programming. The method in question handles specific command inputs. However, since each program that uses this library will have different uses for these commands, I want to leave it up to the user to code their own handling, but require it to be coded in the derived class.

View 2 Replies View Related

C# :: Delete Method Not Working?

Apr 19, 2015

Here is the Method Code:

public void DeleteCustomer(string firstName, string lastName,
string address1, string address2, string city,
string state, string phoneNumber, int customerID)
{

[Code]....

.... And here is the response I get:

Error Deleting customer, please check form data. Syntax error in FROM clause.

View 13 Replies View Related

C# :: How Can A Method Work With Just A Declaration

Feb 28, 2015

I want to access the body of the Add() of a list in c# to see how it works, but it only just gives me the declaration.

[DebuggerTypeProxy(typeof (Mscorlib_CollectionDebugView<>))]
[DebuggerDisplay("Count = {Count}")]
[Serializable]
public class List<T> : IList<T>, ICollection<T>, IList, ICollection, IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable {
public void Add(T item); // thats all. I tried go to declaration but still gives me this line of code. This is from metadata in Visual studio.
}

How this thing work. It just a declaration not a definition yet its still doing something. How is that possible.

View 4 Replies View Related

C/C++ :: Charge Simulation Method?

Sep 26, 2014

how to write a "charge simulation method" program in C or C++? It's to calculate electric distribution and also electric potential of two different dielectrics. I have attached the diagram of the shape of the electrode that needs to be investigated.

View 1 Replies View Related

C# :: Passing Array To Method With GUI

Sep 29, 2014

I have to create a program that accepts 10 numbers from user, and then I display a list of the numbers, the smallest one and the higher number. I have problems with displaying the smallest and higher number, I tried to Array.Sort and Array.Reverse, but I don't know what I'm doing wrong, this is my code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace SmallAndLargeGUI

[Code] ...

Also I tried to set

if (x == 10)
numberTextBox.Enabled = false;

to block the textbox when the user has entered 10 numbers, but didn't work either...

View 4 Replies View Related

C/C++ :: How To Input A Recursion Method

Feb 7, 2015

I am trying to input a recursion method. The code compiles, however, it is only giving me a value of 1. I am wanting the value of 5 when it is compiled. Why is this?

#include <iostream>
using namespace std;
int number(int x) {
if (x == 1)

[Code] ....

View 9 Replies View Related

C Sharp :: Why Use Static Method In C#

Feb 17, 2013

what is static method?

why we can use static method inc#?

View 1 Replies View Related

C++ :: Object Method Does Not Respond

Oct 17, 2012

I am studying the creation of classes in C + +. When executing the code below the method LEN class String2 not work.

code ----------------------------------------------------------------------------------------------
#include <iostream>
#include <string.h>
using namespace std;

[Code]......

View 4 Replies View Related

C++ :: Inherited Method Not Called?

May 6, 2014

OgreWidget.h

Code:

#ifndef __OGREWIDGET_H__
#define __OGREWIDGET_H__
#include <OGRE/Ogre.h>
#include <QGLWidget>
//#include <QX11Info>
class OgreWidget : public QGLWidget {
//Q_OBJECT;

[Code] ....

The inherited method called createScene is not called.

View 1 Replies View Related

C++ :: Calling Subroutines Within DLL

Feb 20, 2013

I am using a dll written in FORTRAN to do some calculations and here is how I have set up the program. I have created following files:

C++ source files:
main.cpp
File1.cpp
Header Files:
Datamain.h
DataFile1.h

[Code]....

Here are my questions:

1) I actually want to call Sub2dll from the main program. But the above program does not build and it gives me the following error: In function 'int main()': Sub2dll was not declared in this scope.

When I build this program with the call to Sub2dll in main commented out and instead put that call in File1::Setup function things build well and runs giving the answer expected. How can I make the call to Sub2dll from main.

2) I am including "Datamain.h" in main. However when I build it with out the declaration int Datamain::Index; in main, it gives me the following error: undefined reference to Datamain::Index When I add that declaration to main the error disappears.

I am usiing Code::blocks with MinGW compiler. I have not put the argument list for the subroutine calls since there were not errors in that part.

View 3 Replies View Related

C++ :: Calling Function In DLL

Jun 8, 2014

I have this sample code, that calls a function in a DLL. The function Callback is provided to the DLL as an argument, in order for the DLL to notify my program of relevant changes.

sample:

#include <iostream>
#include <conio.h>
#include <windows.h>
#include <winbase.h>
#include "TcAdsDef.h"
#include "TcAdsApi.h"
 using namespace std;
 void _stdcall Callback(AmsAddr*, AdsNotificationHeader*, unsigned long);
 
[Code] ....

I would like to change this code, so that there is a Main class that opens the connection and there are several separate classes (as below) that register themselves for a specific variable and get notifications if that value is changed. The reason for this is that I want to get several notifications for several independent events and I don't want them to mix. I figured this should look something like this:

class.h
#ifndef INACLASS_H
#define INACLASS_H
 #include "Main.h"
 class InAClass {
    public:
        InAClass(Main* mainClass, std::string iolocation);

[Code] ....

Unfortunately this gives me an error:
error: cannot convert 'InAClass::Callback' from type 'void (InAClass::)(AmsAddr*, AdsNotificationHeader*, long unsigned int)' to type 'PAdsNotificationFuncEx {aka void (__attribute__((__stdcall__)) *)(AmsAddr*, AdsNotificationHeader*, long unsigned int)}'

At first I thought this was because I don't have the namespace "using namespace std;" on top, but then I should be able to find something that specifically needs to come from the std namespace and is not marked as such. I don't want to rule the option out, but so far I could not find anything like that.

An alternative explanation might be that the Callback function needs to be global, but if I make it global, how can I distinguish between several Callback functions?

View 7 Replies View Related

C# :: Calling A Class Within Itself?

Apr 12, 2015

I created a simple program to understand it

class TestClass {
private int x = 10;
TestClass a = new TestClass();

[Code].....

I know this is recursion but how do the compiler do this? How can it call itself when it hasnt even completed initializing every object it has? Why do VS allow this?

View 1 Replies View Related

C++ :: No Matching Function For Call To Method?

Dec 11, 2014

I need to call one function on my C++ program. I made one root calculator for functions, but, this doesn't work.

// FUNCION QUE CALCULA LA DIFERENCIA ENTRE 2 VECTORES
real mn_error_vectores(Array1D< real > &u, Array1D< real > &v) {
int i;
if(u.dim()!=v.dim()){
printf("mn_error_vectores() : arrays of different dimensions

[Code] ....

View 4 Replies View Related







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