making consistency of data member in the whole programme without using static keyword

making consistency of data member in the whole programme without using static keyword

In the below programme i use one boolean variable named check , which is being accessed inside main function by two objects of Tst1 and Test2 . But the value of check variable is not maintained in the programme . we can use static but i want to know some alternative way ..could anyone give me some hints on it ? Thanks in advance .

Inside jointdeatils.h

#pragma once

class Jointdetails
{
public:
    Jointdetails(void);
    ~Jointdetails(void);
    bool check;


};

Inside jointdeatils.cpp

#include "Jointdetails.h"

Jointdetails::Jointdetails(void)
{
    check = false ;
}

Jointdetails::~Jointdetails(void)
{
}

Inside analyzer.h

#pragma once
#include "Jointdetails.h"
class Analyzer
{
public:
    Analyzer(void);
    Jointdetails* GetJointDetails();
    Jointdetails* m_ptheCTJointDetails;
    ~Analyzer(void);
};

Inside analyzer.cpp

#include "Analyzer.h"
#include "stddef.h"
Analyzer::Analyzer(void)
{
    m_ptheCTJointDetails = new Jointdetails();

}

Analyzer::~Analyzer(void)
{
}
Jointdetails* Analyzer::GetJointDetails()
{

    if(m_ptheCTJointDetails) 
        return m_ptheCTJointDetails;
    else
        return NULL;


}

Inside Test1.h

#pragma once
#include "Analyzer.h"
class Tst1
{
public:
    Tst1(void);
    Analyzer *analyzer1 ;
public:
    ~Tst1(void);
};

Inside Test1.cpp

#include "Tst1.h"

Tst1::Tst1(void)
{
    analyzer1 = new Analyzer ;
}

Tst1::~Tst1(void)
{
}

Inside Test2.h

#pragma once
#include "Analyzer.h"
class Test2
{
public:
    Test2(void);
    Analyzer *analyzer2 ;
public:
    ~Test2(void);
};

Inside Test2.cpp

#include "Test2.h"

Test2::Test2(void)
{
    analyzer2 = new Analyzer ;
}

Test2::~Test2(void)
{
}

Inside main.cpp

#include "Test2.h"
#include "Tst1.h"
#include "stdio.h"

int main()
{
    Tst1 *test1 = new Tst1 ; //check = false
    Test2 *test2 = new Test2 ; //check = false
    test1->analyzer1->GetJointDetails()->check = true ;
    if(test2->analyzer2->GetJointDetails()->check )
        printf("Check value is changed");
    else
        printf("Check value is not changed");
        return 0 ;
}
View Answers









Related Tutorials/Questions & Answers:
making consistency of data member in the whole programme without using static keyword
making consistency of data member in the whole programme without using static keyword  In the below programme i use one boolean variable named check... . But the value of check variable is not maintained in the programme . we can
why using static keyword
why using static keyword  why using static keyword
Advertisements
static keyword in java
.style1 { color: #0000FF; } static keyword in java We are going to discuss about static keyword in java. The static keyword is a special keyword in java programming language. A static member belongs to a class
static keyword
static keyword  please give some detail about Static keyword.   Static Variables Static variables are class variables that are shared... method can access only static data. It can not access non-static data (instance
how to access the object of one frame on clicking a button without using this keyword
how to access the object of one frame on clicking a button without using this keyword  import java.awt.*; import java.awt.event.*; class Mybuttons1 extends Frame { public static void main(String args[]) { Button b1
static keyword
static keyword  Hii, In which portion of memory static variables stored in java. Is it take memory at compile time? thanks deepak mishra
avoid using the whole URL
avoid using the whole URL  How can I avoid using the whole URL
static keyword with real example
static keyword with real example  static keyword with real examplestrong text
Static keyword in public static void main
: static keyword indicates that this method can be invoked simply by using the name... is declared by using static keyword. Following is an example of static declaration...Static keyword in public static void main  Hi, I have seen
Retriving data from MYSQL without line break using java
Retriving data from MYSQL without line break using java  get data without line breaking from mysql table (i.e data stored as mediumtext )using java
data and analytics graduate programme
: data and analytics graduate programme Try to provide me good examples or tutorials links so that I can learn the topic "data and analytics graduate...data and analytics graduate programme  Hi, I am beginner in Data
static keyword in interface
static keyword in interface  Could any one explain,why static keyword implict (or explict ) come in interface? I asked lot of persons about this question, but nobody did not answered clearly. please explain clearly and say what
PHP Static Variable and Methods
should use static methods and variables. Static keyword is used to make only one... of that attribute. Static data are used when some data has to share within... then we can access the method using class, without instantiating any object
static Java Keyword
static Java Keyword       The static is a keyword defined in the java programming language. Keywords... in java programming language likewise the static keyword indicates the following
Access Static Member Of The Class Through Object
Access Static Member Of The Class Through Object  ... that work without any object of the class. Static methods are limited to calling other static methods in the class and to using only static variables
how to retrieve data from database using combobox value without using request.getParameter in jsp - JSP-Servlet
how to retrieve data from database using combobox value without using request.getParameter in jsp  Answer pl
Without Using Form in Java Script
Without Using Form in Java Script  HOw to Reset the data in javascript without using form tag
making of dynamic textfields using swings
making of dynamic textfields using swings  How to make dynamic textfields using java swings
making of dynamic textfields using swings
making of dynamic textfields using swings  how to crate dynamic texfields by clicking on button
programme
programme  Using an ATM, customer can access their bank accounts... programme to implement a simple ATM for 15 customers. Initially you have to store... using array(s). Then the program ask user to input account number and password
without using built-in functions
without using built-in functions  Hai sir... Please help me to solve this... Findout occurances of each string in every another string (built - in functions are not at all allowed) all, and, sand, falling wall and sand
How retreive data from database without using post method in jsp - JSP-Servlet
How retreive data from database without using post method in jsp  Tell me how?  Hi Friend, If you don't want to use post method then use Ajax.We have provided you a link.In that example, with the use of Ajax, we take
How to access sub class member using super class object
How to access sub class member using super class object  class A{ } class B extends A{ int b=1; } class Test{ public static void main(String args[]) { what to do here to access sub class variable b using super class object
Sorting arraylist without using Collection.sort()
Sorting arraylist without using Collection.sort()  Hi, How can I sort an arraylist without using Collection.sort() nad also I am not allowed to use any other data structure in the program? Is there any algorithm by using which I
using tiles without struts
using tiles without struts  Hi I am trying to make an application using tiles 2.0. Description of my web.xml is as follows: tiles org.apache.tiles.web.startup.TilesServlet
messages to the screen without using "document.write()"
messages to the screen without using "document.write()"  To write messages to the screen without using "document.write
static
is applied to member variables, it means that the static variable is shared among all instances of the class. When static is applied to methods, the static keyword...static  what r the main uses of static in java   Hi Friend
demonstrate a) static data members b) static methods
demonstrate a) static data members b) static methods  demonstrate a) static data members b) static methods
java programme
java programme   1.....programme for reading 10 values for 10 variables using scanner class 2....declares all types of primitive data inside main method
Pagination without using database in php
Pagination without using database in php  How can I show multiple images in multiple rows with pagination in php
Making 301 redirection by using <c:redirect>
Making 301 redirection by using   How can i set the status as 301 when using tag? When i use , I am able to redirect to the desired URL (here, Google page) but I get 302 as the status of redirect. I need this status as 301. Any
Breaking a string into words without using StringTokenizer
Breaking a string into words without using StringTokenizer  how can we Break a string into words without using StringTokenizer ??   ... { public static void main(String[] args) { Scanner input=new
Draw graph using jsp without database connection
Draw graph using jsp without database connection  Draw graph using jsp code without database connection
String length without using length() method in java
String length without using length() method in java  How to count length of string without using length() method in java?   Here is Example... the number of character into the given string without using the length() method
Add year to Date without using Calendar in java
Add year to Date without using Calendar in java  how could i add a year to a date function without using calendar functions
ModuleNotFoundError: No module named 'static-data'
ModuleNotFoundError: No module named 'static-data'  Hi, My Python... 'static-data' How to remove the ModuleNotFoundError: No module named 'static-data' error? Thanks   Hi, In your python environment
making a web application using Web-logic server - Struts
making a web application using Web-logic server  Hello Sir
making a web application using Web-logic server - Struts
making a web application using Web-logic server  Hello Sir
In data structure in java how to parse the given string and counts the member of character that match the given data?
In data structure in java how to parse the given string and counts the member of character that match the given data?  Design a parser that parse the given string and counts the member of character that match the given data.using
how to convert string to char array in java without using tochararray
how to convert string to char array in java without using tochararray ...() function. how to convert string to char array in java without using... to char array in java without using tochararray: package my.app; public
Round of to a multiple of 5 without using function
Round of to a multiple of 5 without using function  Please help me out... U enter values like 239, 2543.876, 962.... Give me an equation without using any function which will give output of 240, 2545, 960 respectively
Round of to a multiple of 5 without using function
Round of to a multiple of 5 without using function  Please help me out... U enter values like 239, 2543.876, 962.... Give me an equation without using any function which will give output of 240, 2545, 960 respectively
Java repeat string without using loops
Java repeat string without using loops In this section, you will learn how to repeat string without using for loops. The given example accepts the number of times and iterates the string to the number of times set by the user without
Static variable in java
. Static variable is accessed without creating object of class using class name...Static variable in java. Static is a keyword in java used to create static...; Classname.variablename; Example: Using Static Variable. public class Staticvariable
Member Classes
. Member classes can also use instances of the same class without explicit delegation. Only the member classes can be declared as static. Local... Member Classes      
Can you become a data scientist without a degree?
Can you become a data scientist without a degree?  Hi, I am beginner... to learn: Can you become a data scientist without a degree? Try to provide me... become a data scientist without a degree?". Also tell me which is the good
send without authentication mail using java - JavaMail
send without authentication mail using java  Dear All, I am tring to send simple mail without authentication using java. is it possible, could i send email without authentication. I have written following code. public
Static Variable
of a class, an object, is created. When static is applied to member variables.... When static is applied to methods, the static keyword means that the specified...Static Variable  What is the basic use of introducing static variable
dyanamic upload of images using struts without database connection
dyanamic upload of images using struts without database connection  I want to upload images dynamically with out using data base..and want to create image for every user in my db
Swap two numbers without using third variable
Swap two numbers without using third variable In this section we are going to swap two variables without using the third variable. For this, we have used... from the command prompt. Instead of using temporary variable, we have done some

Ads