{"id":241,"date":"2010-04-29T20:43:14","date_gmt":"2010-04-29T20:43:14","guid":{"rendered":"https:\/\/ibex.tech\/visualcpp\/?p=241"},"modified":"2022-02-17T06:24:05","modified_gmt":"2022-02-17T06:24:05","slug":"global-class-objects","status":"publish","type":"post","link":"https:\/\/ibex.tech\/visualcpp\/classes-objects-struct\/global-class-objects","title":{"rendered":"Global Class Objects"},"content":{"rendered":"<h4>Creating A Global Class<\/h4>\n<p>Often its useful in an application to be able to use an object from anywhere.  On first attempts this seems impossible for managed classes, but the solution is to use a class declared at the global level and have it contain the object you want to access from everwhere.<\/p>\n<h5>Add To stdafx.h<\/h5>\n<pre><code>\r\n#include \"EventLogging.h\"\r\nref class GlobalObjects\r\n{\r\n\tpublic: static MyClass ^MyClass1;\r\n\tpublic: static System::String ^SomeStringName;\r\n};\r\n<\/code><\/pre>\n<h5>Create the object in you main forms constructor<\/h5>\n<pre><code>\r\n\tGlobalObjects::MyClass1 = gcnew EventsLog::EventLogging();\r\n<\/code><\/pre>\n<h5>Then use it anywhere like this<\/h5>\n<pre><code>\r\n\tGlobalObjects::MyClass1-&gt;\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Creating A Global Class Often its useful in an application to be able to use an object from anywhere. On first attempts this seems impossible for managed classes, but the solution is to use a class declared at the global level and have it contain the object you want to access from everwhere. Add To [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-241","post","type-post","status-publish","format-standard","hentry","category-classes-objects-struct"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts\/241","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/comments?post=241"}],"version-history":[{"count":3,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts\/241\/revisions"}],"predecessor-version":[{"id":1120,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts\/241\/revisions\/1120"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/media?parent=241"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/categories?post=241"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/tags?post=241"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}