{"id":516,"date":"2011-01-06T19:52:04","date_gmt":"2011-01-06T19:52:04","guid":{"rendered":"https:\/\/ibex.tech\/visualcpp\/?p=516"},"modified":"2022-02-17T06:24:04","modified_gmt":"2022-02-17T06:24:04","slug":"creating-basic-class-struct","status":"publish","type":"post","link":"https:\/\/ibex.tech\/visualcpp\/classes-objects-struct\/creating-basic-class-struct","title":{"rendered":"Creating Basic Class \/ Struct"},"content":{"rendered":"<p>ref class and ref struct are the same thing.  You could replace class with struct below, but no-one uses struct.<\/p>\n<h5>Define a structure<\/h5>\n<pre><code>\r\n\tpublic ref class DOCINFO\r\n\t{\r\n\tpublic:\r\n\t\tString ^DocumentName;\r\n\t\tString ^OutputFile;\r\n\t\tint ^TheValue;\r\n\t};\r\n<\/code><\/pre>\n<h5>If You Need A Constructor<\/h5>\n<pre><code>\r\n\t\t\/\/----- CONSTRUCTOR -----\r\n\t\tpublic: DOCINFO::DOCINFO()\r\n\t\t{\r\n\t\t\tDocumentName = \"\";\r\n\t\t\tOutputFile = \"\";\r\n\t\t}\r\n<\/code><\/pre>\n<h5>Use it in functions<\/h5>\n<pre><code>\r\n\tvoid MyFunction (DOCINFO ^info)\r\n\t{\r\n\t\tinfo-&gt;DocumentName = \"Hello\";\r\n\t\tint-&gt;TheValue = 10;\r\n<\/code><\/pre>\n<p>or<\/p>\n<pre><code>\r\n\tvoid MyFunction (DOCINFO info)\r\n\t{\r\n\t\tinfo.DocumentName = \"Hello\";\r\n\t\tint.TheValue = 10;\r\n<\/code><\/pre>\n<h5>Define it in functions<\/h5>\n<pre><code>\r\n\tDOCINFO ^info;\r\n\r\n\tinfo-&gt;DocumentName = \"Hello\";\r\n\tint-&gt;TheValue = 10;\r\n<\/code><\/pre>\n<p>or<\/p>\n<pre><code>\r\n\tDOCINFO info;\r\n\r\n\tinfo.DocumentName = \"Hello\";\r\n\tint.TheValue = 10;\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>ref class and ref struct are the same thing. You could replace class with struct below, but no-one uses struct. Define a structure public ref class DOCINFO { public: String ^DocumentName; String ^OutputFile; int ^TheValue; }; If You Need A Constructor \/\/&#8212;&#8211; CONSTRUCTOR &#8212;&#8211; public: DOCINFO::DOCINFO() { DocumentName = &#8220;&#8221;; OutputFile = &#8220;&#8221;; } Use [&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-516","post","type-post","status-publish","format-standard","hentry","category-classes-objects-struct"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts\/516","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=516"}],"version-history":[{"count":5,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts\/516\/revisions"}],"predecessor-version":[{"id":1065,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts\/516\/revisions\/1065"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/media?parent=516"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/categories?post=516"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/tags?post=516"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}