Visual C++ :: Initializing Auto Variables - Cannot Convert Parameter

Sep 8, 2014

I am new to VC++ 2012. I have this code snippet.

Code:
auto it = query_map.find(U("callback"));

The problem is right under the dot there is a red line the error is

Error1error C2664: 'std::_Tree_iterator<_Mytree> std::_Tree<_Traits>::find(const http::uri::encoded_string &)' : cannot convert parameter 1 from 'const wchar_t [9]' to 'const http::uri::encoded_string &'d:maverickprojectsstrikeforcesrcserverserverserver.cpp26

What is the solution to this error?

View 3 Replies


ADVERTISEMENT

C++ :: Cannot Convert From Int And Missing Default Parameter For Parameter 1

Dec 4, 2013

I am developing new project in Qt with existing MFC project . SO in MFC I have a function which uses SYSTEMTime and return CString.

example

CString getTimestampString( void )
{
SYSTEMTIME systemTime;
CString datestr;

[Code]....

PS -> I cant able to make any changes in lib_know as this library is being used by many other projects..

View 1 Replies View Related

C++ :: Initializing Variables In Each Class

Sep 26, 2014

I am working on a homework assignment and have most of the program working, but when I try to compile it keeps telling me to initialize the coin variables in each class. However, they are supposed to be added then removed so I don't want to set them back to zero.

Rewrite the Purse program given in Page 35 with functions to perform insert and remove operations. The function insert (int p, int n, int d, int q) will initialize pennies, nickels, dimes and quarters. The function dollars() will return the dollars. The function remove (int p, int n, int d, int q) will subtract pennies, nickels, dimes and quarters. The function display() returns a new String to print the content of the purse with remaining pennies, nickels, dimes and quarters.

Code:
usingnamespace std;
int insert_money (int *p, int *n, int *d, int *q);
int remove_money (int *p, int *n, int *d, int *q);
int dollars();
int main()

[Code] ....

View 2 Replies View Related

C++ ::  initializing Variables In Program

Oct 24, 2013

I want to know how to make variables during the program. for example in a program i want to have the player be able to create their own spells or add their own weapons to the game without having to edit the source code. i use sfml 2.0

View 4 Replies View Related

C++ ::  Initializing Boost Asio Variables In State Program

May 5, 2014

I am trying to initialize this chunk of code without it starting at the main menu in my state program:

boost::asio::io_service io_service;
tcp::resolver resolver(io_service);
tcp::resolver::query query(argv[1], argv[2]);
tcp::resolver::iterator iterator = resolver.resolve(query);
chat_client c(io_service, iterator);
boost::thread t(boost::bind(&boost::asio::io_service::run, &io_service));
char line[chat_message::max_body_length + 1];

This code came from a example at the boost example list: URL.....I want the networking to start when the multiplayer state initializes. This is how my program basically looks like:

//Main.cpp
main() {
if (!quit) {
while( handleing_events ) {
CurrentState->handleEvents();

[code].....

I tried to put the stuff in extern at states.h, and initialize it at Multiplayer(), but in handleEvents & ~Multiplayer, it says "c" is not defined...

View 8 Replies View Related

C++ :: Return Different Variables Based On Parameter Value?

Dec 4, 2014

Say I have a GetSomething(char type) function which returns two different variables based on what you pass it, like so:

float Flashlight::GetSomething(char type){
if(type == 'x'){
return velocityX;
} else if(type == 'y'){
return velocityY;
} else {
std::cout << "Debug: Programming error getting flashlight velocity
"; } }

On a scale of null pointers to (insert something notably good), how good or bad is this practice? Just asking out of pure curiosity.

View 3 Replies View Related

C++ :: Unable To Convert Parameter To Struct Type

Nov 3, 2013

I am trying to make a automated menu. It shows there are no syntax errors but when compiled it says cannot convert choice from type into to menuItemType. I am not sure what I did wrong. Here is the code

Code: #include <iostream>
#include <string>
#include <fstream>
using namespace std;
struct menuItemType
{
string menuItem;

[Code]...

View 7 Replies View Related

C++ :: How To Generate Auto ID (or Auto Number)

Feb 16, 2012

This code is for (hospital management system).

This code allow you to add patients.

There are two types of patients. which is:
1. Normal patient.
2. Critically ill patient.

once you added any patient. You will be able to show all patient using "ShowAllPatient;" method. -> i want the Auto-increment ID Number to appear for each patient has been added.

And you will be able to call a patient to provide a hospital services for him/her using "GetNextPatient;" method.

I need to generate an Auto-increment Number for each (patient) has been added. (Auto-increment Number) but it just should be different for each patient. For example the first patient will have 1, The second patient will have 2. etc. The Auto-increment number should appear for each patient.

View 14 Replies View Related

Visual C++ :: Direct2D - Auto-resizing Bitmaps

Feb 9, 2013

Apparently the default behavior with Direct2D when rendering is to scale everything I render based on the size of the render target/window. How can I prevent this? I want to decide for myself when to scale the image, regardless of the size of the window.

View 1 Replies View Related

Visual C++ :: Auto-close MSG Box - Without Button And Title

Apr 1, 2015

I referred Auto-close message box.

But i like to view the message box with out title bar and buttons. Is it possible?

View 4 Replies View Related

Visual C++ :: Auto Start Function After Cdialog Was Shown?

Nov 19, 2013

I want to start a time intensive function after showing a modal cdialog. How can I do this?

Starting the function in OnInitDialog do not work because the dialog is not shown, then.

View 10 Replies View Related

Visual C++ :: Program To Auto Login Website - Waiting With Message Loop

Aug 25, 2013

I am writing a program to auto login in a web site. Before making next attempt I have to wait for some time like some 10 seconds(it is configurable). But during waiting UI should not freeze. I wrote code something like this. Here event m_hEvent[1]) will be set by another thread after 10 seconds.The problem is UI still freezes some times!

while(1)
{
//m_hEvent[1] will be set by another thread after 10 seconds
dwRet = MsgWaitForMultipleObjects(1, &m_hEvent[1], FALSE, dwMilliseconds, QS_ALLINPUT);
ResetEvent(m_hEvent[1]);

[Code] ....

View 4 Replies View Related

C/C++ :: Convert Char Variables To String?

Apr 17, 2013

I need to find some sort of method to convert a series of char variables to a string, to be shown in a label. I've searched for two days and experimented myself just as long, and the closest I've gotten simply puts ASCII values into the string with the following command:

label1 -> Text = System::Convert::ToString(fdp8), System::Convert::ToString(fdp7), 
System::Convert::ToString(fdp6), System::Convert::ToString(fdp5), 
System::Convert::ToString(fdp4), System::Convert::ToString(fdp3), 
System::Convert::ToString(fdp2), System::Convert::ToString(fdp1);

fdp1-fdp8 are all char variables.

View 12 Replies View Related

Visual C++ :: Initializing Array In Constructor?

Mar 8, 2015

I am making a tic tac toe program in which they are asking me to have a 3x3 2 dimensional array of integers and have the constructor initialize the empty board to all zeros. They also want me to place a 1 or 2 in each empty board space denoting the place where player 1 or player 2 would move The problem I'm having is, my code initializes the board to all zeros for each element of the array, and prints it out just fine, but I can't figure out how to re-initialize the values in the array to show where each player moves on the board... I was thinking about having a default constructor that has each value set to zero, and then use a setGame function that can change the values on the board to one or two depending on where the player moves....but I don't know if that's possible.....

here is my code

Code:

// header file
#include <iostream>
#include <array>
class tictac {
public:
tictac(int);

[code]....

View 8 Replies View Related

Visual C++ :: Template Parameter Resolving To Nothing?

Apr 2, 2015

Is there an "easy" way to define a template with a template parameter that could resolve to "nothing".

Code:
template <typename T1, typename T2, typename T3>
struct one_to_three {
public:
T1 t1;
T2 t2;
T3 t3;
};

Now I want to be able to instantiate that in such a way that T3 and T2 (if T3 also) resolve to "nothing".

Don't point me at tuple<>, this has to be a single structure. No dummy's, nothing effectively means nothing.

so on Win32

Code:
one_to_three <int, int, int> x;
sizeof(x) == 12;
one_to_three <int, nothing, nothing> y; // whatever 'nothing' needs to be.
sizeof(y) == 4;

T1 will never be 'nothing'
T2 will only be 'nothing' if T3 also is 'nothing' (if it works with T3 not being nothing, that's fine, but it won't get used that way).

Portability is a non-issue, this only needs to work in VS (2010 and higher). The 'real' solution will need up to T10, I have a solution working with SFINAE, but it takes very very long to compile and it's getting very unwieldy if you would need to add T11.

I know it's not an ideal type approach, but it is what it is, this is a necessity due to linking with a legacy API which we don't have control over.

View 9 Replies View Related

Visual C++ :: Implementing Parameter Argument To Exe

Nov 5, 2013

i have this Stealth Injector source from internet so this program is for injecting .dll to an .exe this program was made by someone to used for cheating in online game but i need to use this program in my private server game online to tell the game client .exe the server IP, that is stored in a dll file.. the problem is i don't want the player to directly execute this program, but they need to run the game patcher first to do the patch.. so i need to put some secret parameter argument that will block player from direct execute..

i know nothing about c++ i only know that you need to use main(int argc, char *argv[]) i've try to put something like this

Code:
int main(int argc, char* argv[]){
stringstream sparam;
string param;

[Code].....

the code works fine but the rest of code won't executed..

i've attached the cpp and header files for you guys to check source.rar

View 3 Replies View Related

Visual C++ :: Pass Parameter In Dialog Box

Feb 12, 2014

I need to pass a variable to a dialog box.

Code:
Doc* pDoc;
Dialog dlg;
int input = dlg.DoModal();

When I call dlg.DoModal() I need to somehow pass the pDoc into the dialog box. Everything I need the variable for is taking place inside the oninitdialog function. Is there anyway to pass the variable to that function?

View 2 Replies View Related

Visual C++ :: Calculate Two Summations - Parameter N

Sep 11, 2014

So I'm currently using Visual Studio 2013, and I was left for homework as a beginner programmer to calculate two summations. First the summation of k to n. k=1 and the equation being k^3. The parameter would be n and I need to printf the results for n=5, 33, 100, 442, 3456.

I know that some of the numbers are big values so float or long should be used but how to define these as of yet.

Another is to find the summation
(n)
(k) <<-- one big paranthesis

for values k=8 and n=10, 21, 35, 46, 68

How to start excluding <stdio.h> and int main ... Also, do I have to repeat a new function for every number for n?!

This is what I have so far for something I did differently

// Factoriales Sumatorias

#include <stdio.h>
int suma1 {
int n = 5; // Defino e Inicializo la variable
long sumatoria = 1; // definicion e inicializacion del resultado
while (n <= 5)

[Code] .....

View 3 Replies View Related

C# :: Unable To Implicit Convert Type Int To String Though Declared Variables As String

Mar 26, 2014

Ok, so I'm writing this code and when I build it keeps saying cannot implicitely convert type int to string even though I declared my variables as string. Why is it giving me this error?

private static string Repair()
{
string result="";
string beep;
string spin;
Console.WriteLine("Does your computer beep on startup?:(y,n)");

[Code]...

View 3 Replies View Related

Visual C++ :: Pass More Parameter In Overriding New Operator

Jul 24, 2014

[URL]

class CMyclass
{
public:
CMyClass(BOOL bUseWhichMemManager);
void* operator new(size_t);
void operator delete(void*);
};

I create two memory manager called CMemManager1 and CMemMangaer2, using different algorithms to allocate buffer. Now I want to control which memory manager to be used, when calling new.

I try to add a parameter bUseWhichMemManager to the constructor, but in overrided new function, there are no way to access the parameter. Is there a way to pass more parameters to new operator, such as:

void* operator new(size_t size, BOOL bUseWhichManager);

View 1 Replies View Related

Visual C++ :: How To Refresh Logon Screensaver Parameter Changes

Jan 13, 2014

I have a Windows service that may change the timeout of the logon screensaver in Windows (as described here.) To do that I change the following registry key to the timeout in seconds:

Code:
HKEY_USERS.DEFAULTControl PanelDesktopScreenSaveTimeOut

The issue is that how do I make OS "read" or refresh the actual screensaver timeout after a change in the registry key above?

My practice shows that it is refreshed (for sure) only when I reboot the system, but in my case I need it to be applied without the reboot.

View 14 Replies View Related

Visual C++ :: Write A Function With Array And Int Parameter?

Nov 25, 2012

i need to write a function with an array parameter and an int parameter.

that array has to be filled with first 10 prime numbers that are exact or higher than the int parameter...and then i need an average value of those 10 prime numbers...

The problem is im not really sure how i should do the part to fill the array with prime numbers that are higher than that int??

Code:

int avgprimearray (int higharray[], int somenumber){
}

View 1 Replies View Related

C++ :: Function Parameter Scope - NumArray Not Recognized As Valid Parameter

Sep 28, 2014

My errors are at the end of the program in two function calls within the definition of the InsertByValue function. g++ does not seem to recognize NumArray as a valid parameter.

#include <iostream>
#include <assert.h>
using namespace std;
const int CAPACITY = 20;

/* Displays the content of an int array, both the array and the size of array will be passed as parameters to the function
@param array: gives the array to be displayed
@param array_size: gives the number of elements in the array */
void DisplayArray (int array[], int array_size);

[Code] ....

View 1 Replies View Related

Visual C++ :: Local Variable Be Passed As Parameter Into A New Thread?

Apr 1, 2013

Can local variable be passed as the parameter for a new created thread procedure? Here is the example code:

Code:
void CDLG::some_function()
{
CString strFileName="abc.doc";
//local variable, can it be valid for being passed into the following new thread???
//Can strFileName still be accessed from within the stack of thread procedure?
::AfxBeginThread(ProcessContentThread,(LPVOID)&strFileName);
}

[Code]...

There is another method using variable on the heap,

Code:

void CDLG::some_function()
{
CString strFileName="abc.doc";
CString* pstrFN=new CString(strFileName);
::AfxBeginThread(ProcessContentThread,(LPVOID)pstrFN);
}

[Code]...

I test these code, both methods work as expected, but I doubt whether the first method is a good way. OR if only the second method is the correct way to pass a parameter to a thread.

View 12 Replies View Related

C++ :: Setting Default Parameter Based On Another Parameter?

Jul 2, 2013

Here's my function definition

bool validateNumber(string& text, int min = 0, int max = -1, bool useMin = true,
bool getValid = true)

The code takes the string text, and checks the make sure that the input is valid and safe to convert and use as a number. However, sometimes there is not min, and sometimes there is no max. The lack of min is done by using the parameter useMin, while the lack of max is done by max < min.

My predicament is the following call:
validateNumber(text, -2);

Now, max will be used, even though I don't want it. Ideally, I would want to do something like... int max = (min - 1), ... but that doesn't work. I also can't check to see if the parameter hasn't been changed (that I know of), because the following call would make it look like it hasn't
validateNumber(text, -2, -1);

So the question is, is there a way to do what I want, without having to add in a bool useMax parameter? Or is this my only option? I don't want to do that for simplicity, but if I have to, I have to.

View 3 Replies View Related

Visual C++ :: Storing Some Variables In Disk?

Feb 9, 2014

I am using Visual C++ to write an app. One problem is that the application will allocate a lot of object instances of a specific class CMyObject, maybe 400, 000. This will cause "Out of memory" error when total allocated CMyObject reaches 400,000.

To solve this problem, I just wonder when a new CMyObject instance is created, is it possible to specify so that the instance will allocate on a disk cache, or file mapping instead of the memory space?

View 3 Replies View Related







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