C# :: Method Is Overwriting Both Instance Of Object And Original Object

Jul 3, 2014

I have a method to take a Tile object and make an instances of it based on some data from the original object. Than it is suppose to manipulate the a specific instance and save the results. The first loop through it works but it changes all instance as well as the base.

public static int recurse(int count, Tile[,] b,Huristic h,int check) {
if (check==1) {
boardState.Add(B)/>;
return check;
} if (check == 0)

[Code] .....

View 6 Replies


ADVERTISEMENT

C# :: Constructor Object Reference Not To Set Instance Of Object

Mar 28, 2014

I am trying to use web api in order to return custom json response keys. For this i have return a custom class to return json response

Custom Class:

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;

[Code].....

View 2 Replies View Related

C Sharp :: Object Reference Not Set To Instance Of Object?

May 4, 2013

I have a combobox with Items 1024
2048
4096
8192

String cach = form.comboCache.SelectedItem.ToString();

I am using the above code to retrive an item selected by user,But this line is giving an exception "Null Reference Exception, Object reference not set to an instance of an object"

View 1 Replies View Related

C++ :: How To Get Object Of Original Class From Function Of Other Class Where Other Class Object Is Member Of Original Class

Jan 21, 2013

The case is like

class B{
public:
somedata;
somefunction();
}
class A{
public:
data;
function();
}

in somefunction i want a pointer to current object of class A m new to c++

View 2 Replies View Related

C# :: Object Reference Not Set To Instance Of Object?

Mar 28, 2014

I am using session to pass object from controller to custom class in MVC Web API. here is my code, i am getting error at session.

public HttpResponseMessage Get()
{
var person = db.Persons.ToList();

[Code]....

View 1 Replies View Related

C# :: Getting Instance Object Is Null Compile

Dec 2, 2011

Code:

public class ColorGenetics
{
public static hk1Class jw;
public static linkedClass link;
}

[code]...

Code builds fine but compiler says I tried to use bject link w/o providing an instance. Class linkedClass has an instance of Class hk1Class set to var jw1.I had linkedClass useing the same var jw for the object instance. I changed it to jw1 thinking that would clear it up and it didn't.

View 2 Replies View Related

C++ :: How To Pass Same Instance Of Object In Two Functions

Feb 25, 2014

I need to send same instance of object of a class in two function (Main function and thread function). The class is something like this:

//The class need to have constructor.
Class ABC {
public:
DWORD *IdG;
ABC(int number) {
IdG = new DWORD[number];
}
}obj(32);

The obj(32) is called in following two function. Function F1 is called using thread in main function.

void F1() {
obj.test;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) {
obj.test1;
_beginthread(F1,0,(void*)number);
}

The code works well when the object of class ABC is created as shown above. My problem is the value that is passed in the object ('32') is to be read from the file.

If I read the file and create object separately in Main function and function 'F1' then , function 'F1' is not executed.

How to create same instance of object for Main function and function 'F1' with value passed in the object taken from the file.

View 1 Replies View Related

C++ :: Create 5 Instance Object Of Class Test?

Apr 27, 2014

I am new to C++. I am trying to create 5 instance object of class Test. I wonder if these two codes are the same.

Test testArray[5];
//which one is the correct way or what is the correct way?
for(i=0;i<5;i++)
{
Test testArray;
}

View 2 Replies View Related

C++ ::  How To Create Global Object / Instance Of A Class

Aug 25, 2013

I'm new in object oriented programming. I need creating a global object/instance of a class, that can be used by any function.

View 19 Replies View Related

C++ :: How To Store The Same Instance Of One Object In Multiple Vectors

Feb 4, 2015

If I have a class object and multiple vectors, how do I make sure I store the same instance of that object in both vectors? For instance:

Object object;
std::vector<Object> vectorOne;
std::vector<Object> vectorTwo;
vectorOne.push_back(object);
vectorTwo.push_back(object);

Are the objects in both vectors the same instance of the object? Like if I called vectorOne[0].setValue(somethingDifferent); would the value be changed for the object in both vectorOne and vectorTwo? If not, how do I make sure that I only have one instance of the object I'm trying to store in multiple vectors?

View 15 Replies View Related

C# :: Creating Instance Of A Class Given Its Assembly Object

Jan 15, 2015

Let's say I reference a dll in my project that has an abstract class in it:

public abstract class Module {
public string type;
public abstract string doSomething();
}

And then I have an Assembly object, loaded from a dll that is not referenced in project, but rather loaded during run-time, containing:

public class Tester : Module
{
public static string type = "Test";
public override void doSomething() {
//Stuff being done
return "hello";
}
}

How can I get the value of "type" in the class that is loaded during runtime? How do I use the "doSomething" method of it and get the returned object?

View 8 Replies View Related

C# :: Rain Application - Object Reference Not Set To Instance Of Obj

Mar 2, 2014

I'm trying to make a "Rain" application, by drawing some lines on the form, and then they must fall. So here is my start code:

public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
Random r = new Random();
Graphics paper;
Line line;

[Code] ....

So when I start debugging I get the "Object reference not set to an instance of an object." error. If I remove the comments lines at "timer1_Tick" this error doesn't appear of course. What can I do to escape from this because it follows me everywhere I go />. I tried to make with arrays, but same problem.

View 4 Replies View Related

C# :: Object Instance Not Retaining Field Values

Jun 13, 2014

I have this class:

class Excuse
{...
public string Description { get; set; }
public string Results { get; set; }
public DateTime LastUsed { get; set; }
public string ExcusePath { get; set; }
....}

[Code] ...

When I run it, I do get the messagebox popping up with the correct description, but then nothing happens. When I debug, I see the fields under the UpdateForm() method are set to null.

I'm guessing this happening because it is looking at the 'currentExcuse' that was declared in the form body. I thought however that redeclaring 'currentExcuse' in the method would overwrite this instance or am I wrong?

Do I need an array to make this work?

View 3 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++ :: Object Type Method Return

Apr 29, 2014

I am new to c++ and trying to learn. for instance. i have a struct and method.I am trying to learn what i can do with the method if i define the return type as struct type.

struct S {
int age;
string name;
};
S method() {
//what i can do in here. with the Struct. I mean can i reach members of the struct. etc
}

View 2 Replies View Related

C# :: Determinate Type Of Object And Pass It Through Method

Sep 18, 2014

I got base class called Statistic and inherited classes from it : lsp, cpu, memory. Those methods inheriting some of methods from Statistic and implement also theirself methods. I prepared some new class called ExecuteRequest which is taking Statistic object in the constructor. What i want to achieve is after i put e.g LSP to this class i would like to determinate what specific object it is in this case LSP right? Then having that i would like to put this object to RunRequest method. How can i achieve that? See my code below:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SOAP_testing {
public class ExecuteRequest

[Code] .....

View 14 Replies View Related

C# :: List Initialize In Object Initialization Method

Oct 31, 2014

public class Customer
{
public int Id { get; set; }
public string Name { get; set; }
public List<Order> Orders { get; set; }
public Customer() {
Orders = new List<Order>();
}
}

This object is called as

var cust = new Customer
{
Id = 1, Name = "Khatana", [b]Orders.Add(new Order())[/b]
}

I want to ask, Orders.Add(new Order()) is a wrong way, but why..!!... as List<Order> already has been initialized in Customer constructor, then why it is again required to be initialized in object initialization.
Is this a correct way

List<Order> orders = new List<Order> {aaa.....bb....cc};
var cust = new Customer
{
id = 1, Name = "Khatana", Orders = new List<Order> { orders }
}

Why we need to initialize a list in an object initialization, where as the list has been already initialized in object constructor.

View 2 Replies View Related

C++ :: Will Copy Constructor Does Object Initialization Using Another Already Created Object

Mar 16, 2013

will copy constructor does object initialization using another already created object? I understand that it can be applied for object initialization and not for assignment.Is it correct?

View 10 Replies View Related

C++ :: Importance Of Static Object In A Class And How They Are Different From General Object

Dec 13, 2012

#include "B.h"
class A {
public :
A()
{
s_b = new B();
b = new B();

[Code] ....

In my project i have seen static object as above . But not able to know what is the exact use of it and how they are different from general object .

View 2 Replies View Related

C++ :: What Can't Non-const Object Receive Temporary Object

Sep 11, 2014

a function returns a temporary object like

int myfun(){
int x = 0;
return x;
}

this function will return a temporary integer now void fun1(const int & num); this function can receive from myfun().BUT void fun2(int & num); this function cannot receive from myfun() Why is that, Moreover what is lifetime of a temporary object like one returned in myfun() ???

View 7 Replies View Related

C/C++ :: Get Reference To Text Object With The Name Of Object?

Aug 23, 2013

In Visual Studio 2010 C++
I have a series of existing text objects
The text properties names are
item1_lbl,
item2_lbl,
item3_lbl,
….

Based on a selection I want to change an object. I generate the name of the object I want to change in a string so from this string is there a way to get a pointer to the correct text object that is same name?

View 3 Replies View Related

C++ :: Starting Vertex Array Object At Index Of Vertex Buffer Object

Sep 22, 2014

I'm trying to figure out how I can create a vertex array object at offset of a vertex buffer object.I've created the buffer object. I'd like the "texs" idnex data to start at the texture coordinate content of the vertex_t structure.

Type definitions:

struct vertex_t {
vector3d_t position;
float s; // Texture coordinate s
float t; // Texture coordinate t
};

Code so far:

// How do I make this start at a certain spot of the VBO?!
glVertexAttribPointer(texs, 2, GL_FLOAT, GL_FALSE, sizeof(vector3d_t), nullptr;
//...

View 1 Replies View Related

C :: How To Create An Object

Oct 31, 2013

I have an assignment that asks me to implement a variant of the classic bouncing balls program.

'Each ball should start off at the top of the screen with a random speed in the x direction. Whenever a ball hits a screen boundary it should bounce off at an angle equal to the impact angle and lose some speed. Eventually each ball should come to a rest at the bottom of the screen. Five seconds after coming to a rest a ball should be removed from the screen.'

'Your code must keep track of objects (balls) by placing the object data structures in a linked list. You need to create your own linked list implementation. Below is a brief description of the object programming interface: CreateObject - Create a new object. The function accepts as input parameters a pointer to the SDL screen, a pointer to a model triangle array, and a variable telling the size of the model triangle array. The function returns a pointer to a new object data structure. The model triangle array specified as input parameter should not be shared across objects. (Not sharing the model triangle array allows e.g. objects to have different colors.)

Perform the necessary memory allocation and copying.DestroyObject - Free object. The function accepts as input parameters a pointer to an object data structure. The function should free all memory allocated to represent the object (memory allocated for the model triangle array and the object data structure itself).

Drawobject - Draw object on screen. The function accepts as input parameters a pointer to an object data structure. The function must draw the object on the screen by calling DrawTriangle on each of the model triangles. Remember to update scale, translation, etc., in each triangle data structure before invoking DrawTriangle.

Hint: Do not make the bouncing algorithm too complex. Bouncing a ball off a vertical or horizontal surface can be accomplished without resorting to calculating impact angles.'

The function I'm stuck at, is the first one - createobject.

My first aim is to get one ball on the screen.

Code:

// Create new object
object_t *CreateObject(SDL_Surface *screen, triangle_t *model, int numtriangles)
{
object_t *object = malloc(sizeof(object_t));
object->model = malloc(sizeof(sphere_model));
object->screen = SDL_Surface;
memcpy(*model, object->model, sizeof(object_t));
return object;
// Implement me
}

This is what I've done so far.

View 4 Replies View Related

C++ :: How To Use Object From Another Class

Dec 21, 2013

I have two classes one called Date and the other is University , Date class has two overloaded operators , ostream and istream to take in the data and print them out :

ostream & operator<<(ostream & out, Date & x) {
out<< x.month << "/" << x.day << "/" << x.year ;
return out;

[Code] ....

The University class has an object of type Date called establishDate and I must use this to print out the date along with the University name and location, here's University class :

University.h

class University {
public:
University (); // constructor
friend ostream & operator<<(ostream & out, University & x); // print the university data
friend istream & operator>>(istream & in, University & x); // to read university data

[Code] .....

so how do I use the establishDate object ?

View 2 Replies View Related

C++ :: Getting A Type From Object

Apr 20, 2013

it is not possible to get a type from an object, only from a type. Even with auto, you can only instantiate another type of the same type.I'd like to get a type from an object given another type, mainly because it is less typing and less error prone.

Some psudocode:

Type1 A<X, Y> a;
int b;
Type2 a.InnerType<b>::type c; // obviously won't work

A work around I thought of would be to use functions:

Type1 A<X, Y> a;
int b;
auto c = a.getInnerType(b);

Which is kinda interesting and looks like the way I'm going to go. However, I'm just wondering if there is any other ways of doing this as I don't really want to instantiate an object if I can avoid it (though the optimizer will probably just dump it anyway).

View 2 Replies View Related

C++ :: How To Link An Object To Another One

Jun 27, 2013

I have the following problem, I have an object of a class Subject, and I want that this object points to another object of class Classes, creating a kind of link. How can I do that?

View 4 Replies View Related







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