C# :: Get The Actual String Passed By Reference?

Apr 8, 2015

I have a list of Strings that are passed to a method consecutively by reference from a class. I want to get the string value passed to the method at a point in time. The reason is to perform an if statement.

//this is the class that holds that holds the constants.
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace xxx.Functional.xyz.Login {
public class Constants {
public static String Username = "paul";
public static String Code = "4";

[code].....

View 2 Replies


ADVERTISEMENT

C++ :: Vector Get Passed To A Thread By Value Instead Of By Reference

Aug 25, 2013

I have a function :

void UpdateNotefications(vector <string> &Notefic)

Where I change a vector...

I called it with a thread :

thread t1 (UpdateNotefications, Notefic);
t1.detach();

Though I see that inside the func, Notefic has a val, and outside, it is still empty (after the function is over)...

View 6 Replies View Related

C++ :: Function Passed By Pointers Or Reference?

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

C++ :: Function Having Argument As A Pointer Passed By Reference

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

C++ :: Global Arrays - Passed By Reference To Function

Mar 9, 2013

I currently have multiple functions that use globally declared arrays in my code.

I want to turn them so that arrays are no longer globally declared, but instead are passed by references to the function.

And I have a function caller inside main, and other functions are called within the function.

View 3 Replies View Related

C++ :: Multiple Objects Passed As Reference To Function

Apr 23, 2013

Essentially, the 'Sequence' below uses linked lists to store data. If 'result' refers to the same sequence as 'seq1' or 'seq2', I want 'result' to refer to a new sequence. This new sequence can be default constructed (no copy of 'seq1' or 'seq2' is required). I can't seem to do this correctly. Also, the prototype of the function cannot be altered.

void fun(const Sequence& seq1, const Sequence& seq2, Sequence& result) {
// Check for reference to same sequence. If they are the same,
// create new sequence for 'result' to refer to
if ((&seq1 == &result) || (&seq2 == &result)) {

[Code] ......

View 4 Replies View Related

C++ :: How To Convert String To Double Without Changing Actual Data

Jun 3, 2013

I have to convert string to double. i'm using "atof" function to achieve same.

I have string as "0.0409434228722337" and i'm converting with "atof" But i'm getting double value as "0.040943422872233702". Why it adds 02 additionally at the end?

More example :

"0.0409434228722337" converts to "0.040943422872233702"
"0.067187778121134" converts to "0.067187778121133995"

Is there any other possibility to convert string to double without changing data ?

View 5 Replies View Related

C++ :: Object That Is Passed To Function Is Changed Although No Pointer Is Passed

Mar 22, 2013

I am posting this simplified piece of code that is a bit confusing for me. There are two functions that I call. One shows the expected results but the result of the other one rather puzzles me.

//#define defineVecTyp Vec3f
#define defineVecTyp float
template <typename vecTyp>
vecTyp buildLaplacianPyramid(cv::Mat inputmat) {
vecTyp lapPyr;

[Code].....

Calling the function sum1 does not change the values stored in the variables val1 and val2. The output of the program is as follows:

val1= 1 ## val2= 10 // before the call of function sum1
val1= 1 ## val2= 10 // after the call of function sum1
sumOfVals= 22

This is quite obvious and as expected and I just pasted this piece of code as an example for better clarification.

However, if I call the function buildLaplacianPyramid and apply a function for Gaussian Blurring, this also effects the cv::Mat passed to the function. The line imshow("M1, after buildLaplacianPyramid",M1); therefore shows an image that is blurred. Since I am not passing a pointer to the cv::Mat I do not understand why this should be happening. I was assuming that there would be a copy of the cv::Mat M1 to be used within the function. Therefore I was expecting the cv::Mat M1 to retain its original value. I was expecting that all changes applied to cv::Mat inputmat within the function would not have any influence on the cv::Mat M1. Just like in my other example with the sum.

View 3 Replies View Related

C++ :: Unsigned Char To String And Being Passed Into Function

Mar 24, 2015

I have the following code, but it crashes on the "data = " line...

Code:
void Test(string& data) {
unsigned char* msg = (unsigned char*)malloc(MAX_LENGTH));
...
data = string(reinterpret_cast<const char*>(msg), MAX_LENGTH);
}

I know I could just return string, but what is wrong with this code that is making it crash?

View 6 Replies View Related

C++ :: Function Works When Passed String Literal But Not A Variable

Jul 10, 2014

I'm making a .json loader for a project that I'm working on, and to simplify things, I decided to make all the root attributes named in a separate file. Here's my problem: my loading function, Add(const char* id), works just fine when I pass it a string literal.

However, when I use a function that iterates through a vector list, even with the exact same definitions as the literal, it returns the error: std::out_of_range at memory location 0x0026fb30

I've stepped through it with the VS2010 debugger about a hundred times, checked against memory locations, and just have done everything I can think of, all to no avail..

The code, with data-checking omitted:

The std::map I'm adding to:

static std::map<const char*, Item*> *s_mItems;
Initialized as std::map<const char*, Item*> *Item::s_mItems;

Add() Function (Works by itself with a literal):

static bool Add(const char* id) {
...
std::string name = node.Get("name").ToString();
std::string desc = node.Get("description").ToString();
int rarity = StrToRarity(node.Get("rarity").ToString());

[Code] ....

AddList() function, where the program always breaks:

static void AddList(std::vector<std::string> list) {
for(std::vector<std::string>::iterator it = list.begin(); it != list.end(); it++) {
Add(it->c_str());
}
}

View 3 Replies View Related

C/C++ :: SDL LoadBMP Fails To Load A Passed String Literal

Jan 24, 2014

Background: I'm using SDL and CodeBlocks and trying to make a Graphics class that would simplify some SDL operations such as drawing and loading images.

Issue: The loadImage function in the graphics class fails to load the image correctly and so the program prints out a blank window during run-time. I've tried multiple ways of passing a string literal into the function the surface temp fails to load and so background in Game fails to load. After testing it several times, I'm pretty sure that the issue lies with SDL_LoadBMP not registering the passed variable for whatever reason. I know the image is in the right place as writing SDL_LoadBMP("./Graphics/image.bmp"); brings it up just fine.

Current Code:

Main simply creates a Game object and execute(), so I didn't feel the need to put it on here.

Game.h
#ifndef GAME_H
#define GAME_H
#include "SDL/SDL.h"
#include "SDL/SDL_ttf.h"
#include "Graphics.h"
#include <string>
#include <cstring>
using namespace std;

//GLOBAL CONSTANTS
//game window settings

[Code] ....

Output: A blank window. (It should show the background image but doesn't.)

Note: I originally wrote it as gfx.loadImage(background, "./Graphics/image.bmp") but that gives me a conversion warning and still fails to show the image when the program runs. I've tried looking up examples similar to what I was doing but no one else seems to have this problem.

View 3 Replies View Related

C++ :: Convert Passed String Into Proper Alpha Case And Sort Array Of Names

Apr 25, 2013

I want to create 2 functions to (1) convert a passed string into proper case (capitalize the first alpha character of a string and every alpha character that follows a non-alpha character); (2) sort the array of names (after it has been converted to proper case).

I tried these two:

console.writeline (lower.toUpper());
void bubblesort (string array[],int length);

but I don't know if they are good.

View 2 Replies View Related

C++ :: Passing String Using Reference Operator

Aug 28, 2014

Why it is necessary to use the reference operator here ?

const string& content() const {return data;}

Example in [URL] ....

// classes and default constructors
#include <iostream>
#include <string>
using namespace std;

class Example3 {
string data;

[Code] .....

View 2 Replies View Related

C++ :: Reference To A String In Function Parameters

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

C# :: Null Reference With Connection String

Nov 29, 2014

private DataSet1 GetData(string query) {
string conString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;

The above is erring out with NullReferenceException

View 6 Replies View Related

C++ :: Converting Reference Address To Character String

Jun 15, 2014

I'm wanting to convert the reference address held by a pointer into a character string, combine the hexes into a single unsigned long int(using bitwise operators )so I can use the 32bits in conjunction with a separate algorithm to develop a more efficient, but less 'random', number, or should I say bit, generator that I'll be using in a Neural Network, with Genetic Algorithms used to modify the weights.

View 5 Replies View Related

C++ :: Explicit Conversion From String To Class Reference?

May 10, 2013

following code that I'm reading out of the book "The C++ Standard Library".

class C
{
public:
explicit C(const std::string & s); // explicit(!) type conversion from strings.
...

[Code].....

Now I understand that they are saying that an explicit conversion isn't allowed but what I don't understand is what explicit conversion would be happening if there was one allowed.

Specifically I don't understand the const C & elem syntax. How does this work since the collection holds strings. What would be the syntax for how this:

const C & elem

gets strings. I was thinking it was a class reference that someone how converts to a constructor function pointer or something but i'm really confused.

View 4 Replies View Related

C++ :: How To See Actual Size Of PTR

Sep 26, 2014

How can I see the actual byte size of the pointer as output in the command prompt?

#include <iostream>
using namespace std;
int main () {

[Code].....

View 2 Replies View Related

C++ :: What Is The Actual Use Of Function Pointer

Dec 27, 2013

two things I did'nt get till now

Q->1 what is the actual use of function pointer ?

Q->2 what is use of passing function as an argument to another function ?

View 2 Replies View Related

C++ :: Converting Octal Value To Actual Number?

Jan 22, 2015

I'm a games/apps developer and right now I'm developing games/apps for iOS, Android and also PC / Facebook. I've also been working on C++ for some time but since I'm learning it all by myself, I still have some beginner doubts.

Is there any easy way to code a value conversion (for example an octal value to an actual number)?

View 2 Replies View Related

C/C++ :: What Is The Actual Concept Of Delete Operator

Dec 31, 2012

I am not getting the real concept of delete operator. If it deallocates the memory, then why i am getting such output..!!

int main() {
    int *a , b=5;
    a = & b;
    cout << *a << endl;
    delete a;
    cout << *a;
    getch();
    return 0;   
}

Output:
5
5

View 4 Replies View Related

C++ :: Display Actual Number Without Leading Zeros

Jan 20, 2014

With the loop below, is there a way to display the actual number without the leading zeros (scientific notation) or will it just display 0 since there are so many leading zeros?

num = 1;
while (num > 0){
num /= 2;
}
cout << num;

View 6 Replies View Related

C :: Not Getting Actual Output While Displaying Hex Numbers In Decimal Format

Apr 26, 2013

I need to display 0-15 hex numbers[0X00-0x0F] in decimal value...& I'm getting the output but it's not exactly what it should be,below is my code.. [This not the complete code,but main part where the changes are done]

Actual output i should get is for 1v it should generate 0001,for 2v it should generate 0010 and simultaneously till [15v-1111]... But what i'm getting is exactly different to this for eg for 7v,8v&9v the bits generated are 1101,1011,1011 respectively...

[URL] ....

Code:
sbit V1 = P2^0;
sbit V2 = P2^2;
sbit V3 = P2^4;
sbit V4 = P2^6;
#define DAC_table V1,V2,V3,V4

#include <stdio.h>
#include <string.h>
idata unsigned int ptr2tbl ;

[Code] .....

View 2 Replies View Related

C++ :: Program To Find Actual Distance Between Two Points On A Grid

Jul 3, 2013

Currently I am working on a program that will find the actual distance between two points on a grid. It also determines the angle of the line segment in degrees. Now, i need it to be able to find any other points on or near the line. It will be running in a loop to find each additional point sequentially until all the points have been plotted. Unfortunately, I am not entirely sure how this is done. So far, I think that I could develop an algorithm that converts the angle into a ratio of vertical movements to horizontal ones.

View 7 Replies View Related

C# :: Display Listview Items In Actual System Fonts

Sep 11, 2014

I'm trying to use a listview component to show all the fonts on my system, and display each item (row) in the actual font design.

When I run the following code, nothing displays in the listview.

If I rem out line 4, then the list populates with all the fonts, but of course, in the default listview font.

I thought I read somewhere that each item in a listview can be set to a different font.

int i = 0;
foreach (FontFamily oneFontFamily in FontFamily.Families) {
listView1.Items[i].Font = new Font(oneFontFamily, 10);
listView1.Items.Add(oneFontFamily.Name);
i++;
}

View 10 Replies View Related

C++ :: Trace Function - How To Display Actual Values In Console

May 24, 2014

Code:
Real x = (arg.state.X.abs - mViewport->getActualLeft())/float(mViewport->getActualWidth());
Real y = (arg.state.Y.abs - mViewport->getActualTop())/float(mViewport->getActualHeight());
_trace("%f %f
", x,y);

Code:
#include <Windows.h>
#ifdef _DEBUG
bool _trace(TCHAR *format, ...) {
TCHAR buffer[1000];

[Code] .....

Results:
f f
f f
f f
f f

How to display the actual values in the console?

View 4 Replies View Related







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