I've been trying to get this Sudoku game working, and I am still failing some of the individual functions. All together the game works, but when I run it through an "autograder", some test cases fail..
Currently I am stuck on the following function, placeValue, failing. I do have the output that I get vs. what the correct one should be, ...
I have this program, but cin in randomly skips.. I mean sometimes it does, and sometimes it doesn't. Any ideas how to fix this?
int main(){
/** get course name, number of students, and assignment name **/
string course_name;
int numb_students;
string assignment_name;
Assignment* assignment;...
#include <stdlib.h>
#include <iostream>
#include <memory>
#include "copy_of_auto_ptr.h"
#ifdef _MSC_VER
#pragma message("#include <string>")
#include <string>
// http://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html#Diagnostic-Pragmas
#endif
/*
case 1-4 is the requirement of the auto_ptr.
which form http://ptgmedia.pearsoncmg.com/...
Hi all, I want to ask about pointer in C++
I have some simple code:
int add(int a, int b){
return a+b;
}
int runner(int x,int y, int (*functocall)(int, int)){
return (*functocall)(x,y);
}
now, suppose I call those functions using this way :
cout<<runner(2,5,&add);
or maybe
cout<<runner(2,5,add);
is there any difference? beca...
Hi everyone, I'm getting weird string corruption across JNI calls which is causing problems on the the Java side. Every so often, I'll get a corrupted string in the passed array, which sometimes has existing parts of the original non-corrupted string. The C++ code is supposed to set the first index of the array to the address, it's a nas...
Right so i'm trying to use a C library in C++, never actually done this before i thought it would be a case of declaring the header includes under a extern "C" and setting the compile as flag to "default" but i'm still getting linker errors and think that the header file might have to be complied as a DLL. I have no idea really.
Is it ...
Adding functionality to a class can be done by adding a method or by defining a function that takes an object as its first parameter. Most programmers that I know would choose for the solution of adding a instance method.
However, I sometimes prefer to create a separate function. For example, in the example code below Area and Diagonal ...
What's the difference between these:
This one works:
char* pEmpty = new char;
*pEmpty = 'x';
However if I try doing:
char* pEmpty = NULL;
*pEmpty = 'x'; // <---- doesn't work!
and:
char* pEmpty = "x"; // putting in double quotes works! why??
EDIT: Thank you for all the comments:
I corrected it. it was supposed to ...
Hello, we are tasked with basically emulating a browser to fetch webpages, looking to automate tests on different web pages. This will be used for (ideally) console-ish applications that run in the background and generate reports.
We tried going with .NET and the WatiN library, but it was built on a Marshalled IE, and so it lacked many...
So this is something that I've always wondered but was never quite sure about. So it is strictly a matter of curiosity, not a real problem.
As far as I understand, what you do something like #include <cstdlib> everything (except macros of course) are declared in the std:: namespace. Every implementation that I've ever seen does this by ...
Does C++ have a proper implementation of interface that does not use vtable?
for example
class BaseInterface{
public:
virtual void func() const = 0;
}
class BaseInterfaceImpl:public BaseInterface{
public:
void func(){ std::cout<<"called."<<endl; }
}
BaseInterface* obj = new BaseInterfaceImpl();
obj->func();
the call to func at the ...
I'm new to C++, so bear with me. I have a generic class called A. A has a nested class called B. A contains a method called getB(), which is supposed to return a new instance of B. However, I can't get my code to compile. Here's what it looks like:#include
A.h
template <class E>
class A {
public:
class B {
public:
...
Based on this question I understand the purpose of the construct in linking C libraries with C++ code. Now suppose the following:
I have a '.so' shared library compiled with a C++ compiler. The header has a 'typedef stuct' and a number of function declarations. If the header includes the extern "C" declaration...
#ifdef __cplusplus
ext...
I am looking for a way to set a warning that the caller will have to respond to. In a sense I would like to use a late exception mechaninism that occurs after the function already finished executing and returned the wanted value.
SomeObject Foo(int input)
{
SomeObject result;
// do something. oh, we need to warn the caller. ...
I noticed today that a source code file in a project was compiling even though it had junk at the top of it. It got me wondering what all would pass without error through the compiler. Here is an example of code that will not generate any error messages:
what kind of weird behaviour is this???
#include "stdafx.h"
// what is up?
int...
I have the following code:
// Incrementer
datastores.cmtDatastores.u32Region[0] += 1;
// Decrementer
datastores.cmtDatastores.u32Region[1] = (datastores.cmtDatastores.u32Region[1] == 0) ?
10 : datastores.cmtDatastores.u32Region[1] - 1;
// Toggler
datastores.cmtDatastores.u32Region[2] =
(datast...
I have some struct:
struct A
{
const char* name_;
A* left_;
A* right_;
A(const char* name):name_(name),
left_(nullptr),
right_(nullptr){}
A(const A&);
//A(const A*);//ToDo
A& operator=(const A&);
~A()
{
/*ToDo*/
};
};
/*Just to compile*/
A& A::operator=(const A& pattern)
{
//check for self-assignment
if (this ...
I've been banging my head...I can't pretend to be a C++ guy...
TCHAR * pszUserName = userName.GetBuffer();
SID sid;
SecureZeroMemory(&sid, sizeof(sid));
SID_NAME_USE sidNameUse;
DWORD cbSid = sizeof(sid);
pLog->Log(_T("Getting the SID for user [%s]"), 1, userName);
if (!LookupAccountName(NULL, (LPSTR)pszUserName, &sid, &cbSid, NUL...
This is related to my previous question, regarding pulling objects from a dmp file.
As I mentioned in the previous question, I can successfully pull object out of the dmp file by creating wrapper 'remote' objects. I have implemented several of these so far, and it seems to be working well. However I have run into a snag.
In one cas...
One of our customers is complaining our application is not working. Their reasoning is that our sql function call to their Oracle database is not getting the "expected" result. Sometime, it should failed but our application get success from their database. It's really frustrating because it's their database and we cannot do any test on i...