C++ :: Resize Array - No Constructor Could Take The Source Type

Apr 25, 2013

i have 1 class with several class's and 1 structure:

Code:
struct Images {
HBITMAP ImageImage;
BITMAP Imagebm;
HDC ImagehdcMem;
HBITMAP ImageMaskImage;

[Code] .....

But I get these error:
"--------------------Configuration: Sprite2 - Win32 Debug--------------------
Compiling...

Test Sprite2.cpp
C:UsersJoaquimDocumentsVisual C 98Sprite2Test Sprite2.cpp(23) : error C2440: 'type cast' : cannot convert from 'void *' to 'struct Images'
No constructor could take the source type, or constructor overload resolution was ambiguous
Error executing cl.exe.

Sprite2.exe - 1 error(s), 0 warning(s)"

I try search more code, but i get more errors ...

View 14 Replies


ADVERTISEMENT

C++ :: No Constructor Could Take Source Type Or Constructor Overload Resolution Was Ambiguous

Mar 1, 2014

i am writing this bank accounts program using structures. i haven't implemented the function before that i want to check if the data is being read and printed. When i build and run the program in visual studio it gives me the following error. "No constructor could take the source type, or constructor overload resolution was ambiguous". Now whats wrong in this program?

/* Bank Accounts Program */
#include <iostream>
#include <string>
#include <fstream>
#include <cstdlib>//needed to use system() function
using namespace std;
const int MAX_NUM = 50;
struct Name{

[code]....

View 1 Replies View Related

C :: Can't Get Array To Resize

Jan 6, 2015

I have an array of blocked users and I want to be able to increase the element size every time a new user is to be blocked.

The blockedUsers array and blockedCount int are global varaibles

Code:
int blockedCount = 0;
char ** blockedUsers; Code: int blockUser(char *username)
{
int i = 0;

[Code]....

View 11 Replies View Related

C++ ::  Dynamic Array Resize Function

Apr 22, 2014

I made a resize function for my dynamic array template class that goes as follows. Note that the private member variables are T* arr, unsigned used, and unsigned cap.

template <class T>
void darray<T>::resize(unsigned size) {
if (size > cap) {
T* temp_arr = new T[size];

[Code] ....

Whenever I use this function to increase the size of the array, it will work the first time I need to use it, but after that, Visual Studios will trigger a breakpoint at line 14, and if I continue past the breaks, I eventually get _CrtIsValidHeapPointer(pUserData) assertion failure.

View 4 Replies View Related

C :: Dynamic Memory Allocation - Resize Array Of Pointers

May 23, 2013

Suppose I wished to reallocate memory (resize) an array of pointers. Why does the following not work?(The program runs, yet yields a faulty segmentation error message. Why?):

Code: char **ptrarr = (char**) malloc(sizeof(char*))

Code: ptrarr = (char**) realloc(ptrarr, (capacity) * sizeof(char*));

View 14 Replies View Related

C :: Declaration Of Array In Another Source File

May 5, 2014

I was going through a code where i found the definition of int array[63] in one of the source files. But i also found the declaration as extern int array[66] in another source file. This is clearly wrong, but my doubt is how the compiler compiled it. It should have thrown error. In case if it compiles then what will be the behavior of the system? Will it be normal or some undefined behavior?

View 3 Replies View Related

C++ :: Changing Array Of Numbers Of Type Char To Type Int?

Apr 27, 2013

I'm having some problems with changing an array of numbers of type char to type int. Every time i try to sum 2 array indexed values it returns some letter or symbol. Also, if i change the type of the array in the functions the compiler gives me an error message. I would also like to add that the problem requires that the first two arrays be char so each individual number gets assigned to a different value.

My current code is:

Code:
#include <iostream>
void input(char a[], char b[], int& size_a, int& size_b);
void convert(char a[], int size);
void reverse(char a[], int size);
void add(char a[], char b[], int c[], int size);
int main()

[Code]....

View 4 Replies View Related

C++ :: Convert Element Of Int Type Of Array To Char Type?

Dec 21, 2013

how to convert an element of int type of an array to char type?

View 2 Replies View Related

C++ :: Write A Source Code That Find Smallest / Largest And Average Of Numbers From Array

May 13, 2014

im trying to write a source code that find the smallest, largest and average of numbers in array. the code runs fine, but it is not giving the highest number and the the average should include only four number excluding highest and smallest number from the array.

void OlympicJudging() // Olympic Judging {
int numbers [6];
double average, sum = 0;
int temp;
for(int i = 0; i < 6; i++){
cout << "Please type a value for scores: ";
cin >> numbers[i];

[Code]...

View 5 Replies View Related

C++ :: Constructor Not Initializing Array?

Mar 6, 2015

I am making a tictactoe program that requires me to have a 3 by 3 two dimensional array of integers, in which the constructor should initialize the empty board to all zeroes. The program complies, but it keeps outputting garbage values and i'm not entirely sure why, My print function isn't complete yet, since I want to print out the array in a tic tac toe format, but i'm more concerned with why it's printing garbage values, here is my code:

Code:

// header file
#include <iostream>
#include <array>

[Code] ....

View 7 Replies View Related

C++ :: Constructor Array Copy

Nov 12, 2013

In the below program, how can copy the array n[] into Array[]. The below is not working..

#include <iostream>
using namespace std;

class arrayPlay {

[Code] .....

View 1 Replies View Related

C++ :: Initialize Array In A Constructor?

Dec 6, 2013

There are two class.How can I initialize an array of different class in a constructor?

class Ticket{
private:
int ID;

[Code]....

I have to provide a no-argument constructor (Cinema();)to initialize the ticket array and give the right ticket ID.

View 1 Replies View Related

C++ :: Array Of Structs With Constructor?

Apr 1, 2013

I can't seem to remember everything I should about constructors. I'm looking for a way to create an array of structs, using a constructor. My code should explain.

struct myStruct
{
private:
int structInt1, structInt2;

[Code].....

View 2 Replies View Related

C/C++ :: How To Pass Array To A Constructor

Feb 24, 2012

I want to pass an array to a constructor, but only the first value is passed--the rest looks like garbage. Here's a simplified version of what I'm working on:

#include <iostream>  
class board {
    public:
        int state[64];
        board(int arr[])

[Code] ....

Why this doesn't work and how to properly pass an array? Notes: I don't want to copy the array. Also, I'm using MSVC++ 2010 Express.

View 1 Replies View Related

C :: Resize A Bitmap Image

Aug 22, 2014

I am trying to re-size a bitmap image for a class.They gave us two options to use to do the program with: an array or move the file position indicator. I want to use the file option. All the bitmap header info is checking out. The file after being re-sized should be 822 bytes but it is 1.6 KiB and the image is distorted.

Code:

#include <stdint.h>
/**
* Common Data Types
*
* The data types in this section are essentially aliases for C/C++
* primitive data types.

[Code]...

View 2 Replies View Related

C++ :: Making Constructor For Array Of Character

Jan 16, 2015

Code:
class Robot{
char name[15]; //assign to char n
int x, y , direction;
void ToString(int d);

[Code]......

how do i assign char name[] in the class to char n in the constructor?

View 3 Replies View Related

C++ :: Can't Initialize String Array In Constructor

Jul 22, 2013

I am currently practicing designing classes. In one exercise, I am trying to store 15 words in an array, and randomly print one (using the rand() functions and seeding it with crime. I have a header file, a respective .cpp file, and a main .cpp file. When I try to compile the code using g++ GuessWord.cpp UseGuessWord.cpp -o UseGuessWord, I get the following error in my constructor: expected primary-expression before ‘{’ token

Here is my code:

header file (GuessWord.h):
#ifndef GUESSWORD
#define GUESSWORD
#include <string>
using namespace std;

[code].....

View 2 Replies View Related

C++ :: Faulty Use Of Constructor Of Dynamic Array

Aug 28, 2014

One can initialize a dynamically created array in the following way:

unsigned int * vec;
// ... do something to vec
double * a = (double *) malloc(4*sizeof(double));
a = (double[3]){(double[3]){0.0,10.0,20.0}[vec[0]],

[Code] ....

While there is no compilation error for the first assignment, the memory a is pointing to seems to change, surprisingly to me. This seems to solve the problem though:

memcpy(a, (double[3]){(double[3]){0.0,10.0,20.0}[vec[0]],
(double[3]){1.0,2.0,3.0}[vec[1]],
(double[6]){-2.0,-1.0,0.0,1.0,2.0,3.0}[vec[2]]
},
3*sizeof(double)); // NO C COMPILER ERROR

What does the first assignment do and why does it cause memory to change later in the program?

View 2 Replies View Related

C++ :: Copy Constructor With Array Crashing

Oct 7, 2014

I know everything works except my copy constructor! There are no errors. The program crashes when it goes to access the copy constructor. why the copy constructor isn't working?

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <cstring> // access to C str functions
#include "String.h" // access String class
using namespace std;
String::String( int size )// default constructor

[code].....

View 2 Replies View Related

C/C++ :: Constructor To Initialize Each Members Of Array?

May 3, 2014

Need a C++ constructor to initialize each members of an array. how to give value for for each elements of an array declared as a class object according to the users input.

View 1 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

C++ :: Calling Constructor From Constructor Set Pointer To Null

Jan 25, 2014

VS 2012 / Windows 7 64 bit

class
class myclass {
public:
myclass(){/*stuff here*/}
myclass(int* p) {MyPointer = p; myclass()}

[Code] ....

it works until the myclass(int* p) calls myclass()

then the MyPointer will become CCCCCCCC (NULL value)!

is there a way to stop the second constructor from resetting the pointer value to null?

View 3 Replies View Related

C++ :: Vector Syntax - Resize And Reserve

Mar 7, 2014

We can construct vector in following ways

vector<int>v1; //create an empty vector
vector<int>v2(arr,arr+4); ///to create vector from an array
vector<int<v3(v2); //throuh copy constructor

But I have come across some program in a forum,they have create vector like this

vector<int>v(10,5)

I am clueless ,is this allowed?,what syntax allows this?

if a vector is create like this

vector<int>v(3);
v.push_back(1);
v.push_back(2);
v.push_back(3)
v.resize(2);

Now I am curious to know what are the changes those will happen in vector v because of resizing it?

View 1 Replies View Related

C++ :: Set Vector Step Length When Resize?

Jan 5, 2013

When I use vectory.push_back(obj), if the length is out of reserved bound, it will deallocate the whole vector and reallocate a big piece of memory. From my understanding I think c++ only allocates 1 more place for the new obj. This is quite inefficient. Is there a way to set the step length whenever the size is out of bound? e.g. 50 more spaces.

View 6 Replies View Related

C# :: Resize Quadrilateral Image According To New Points

Nov 22, 2014

I have a bit map which I wants to re-size according to new point. But on Paint Event Method getting error not Implemented.

CODE Under Paint Event Method

private void pictureBox3_Paint(object sender, PaintEventArgs e) {
Point[] destinationPoints = {new Point(200, 20),new Point(110, 100),new Point(250, 30), new Point(250, 30) };
Image image = new Bitmap("D:\APP\Resources\MyPic.Png");
// Draw the image mapped to the parallelogram.
e.Graphics.DrawImage(image, destinationPoints);
}

View 5 Replies View Related

C# :: Keep Aspect Ratio When Resize Form

Dec 15, 2014

When I try to resize my form, every time i try to resize it while running, the window blinks between original size and the new size it was given, when i release the mouse it either stay in its new size or shrinks back to its original size, What makes it return to its original size, maybe its something with the form_Resize function..

private bool inForm_Resize = false;
private Size PrevSize;
private void Form1_Resize(object sender, EventArgs e) {
double dRatio = 1.6;
if (!inForm_Resize) {
inForm_Resize = true;

[Code] ....

View 3 Replies View Related







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