class

Call Delphi CLASS exported in DLL from C++ code

。_饼干妹妹 提交于 2021-02-04 21:39:14
问题 i have a problem to use delphi class from C++ code. delphi dll demo that export a function that return an object. my delphi Dll code is as follow: library DelphiTest; // uses part.... type IMyObject = interface procedure DoThis( n: Integer ); function DoThat : PWideChar; end; TMyObject = class(TInterfacedObject,IMyObject) procedure DoThis( n: Integer ); function DoThat: PChar; end; // TMyObject implementation go here ... procedure TMyObject.DoThis( n: Integer ); begin showmessage('you are

Will be initialized after warning fix

非 Y 不嫁゛ 提交于 2021-02-04 21:35:44
问题 good evening (and happy thanksgiving), I have the following code (ripped out of my main code into a standalone file) and am getting some warning messages that I'd like to resolve. Here is the code: #include <cassert> #include <ostream> #include <climits> #include <iostream> #include <string> using namespace std; class WordCount { public: // Constructors WordCount() : word(""), count(0) { } WordCount(string theWord, unsigned theCount = 1) : word(theWord), count(theCount) { } // Accessors

Will be initialized after warning fix

ⅰ亾dé卋堺 提交于 2021-02-04 21:30:21
问题 good evening (and happy thanksgiving), I have the following code (ripped out of my main code into a standalone file) and am getting some warning messages that I'd like to resolve. Here is the code: #include <cassert> #include <ostream> #include <climits> #include <iostream> #include <string> using namespace std; class WordCount { public: // Constructors WordCount() : word(""), count(0) { } WordCount(string theWord, unsigned theCount = 1) : word(theWord), count(theCount) { } // Accessors

Any way to initialize this variable based on class template type?

微笑、不失礼 提交于 2021-02-04 21:08:16
问题 I have a class stats with a template so that it can be flexible. I'm new to templates though, and I thought the point of them was to make it flexible around the user. So I feel like I'm doing something wrong seeing as I've hit a small wall. #include <iostream> #include <cstdio> #include <iomanip> template <typename T> class stats { private: int n; T sum; public: stats() { this->n = 0; this->sum = T(); } void push(T a); void print(); }; int main() { std::string tmp; // change type based on

Any way to initialize this variable based on class template type?

核能气质少年 提交于 2021-02-04 21:05:28
问题 I have a class stats with a template so that it can be flexible. I'm new to templates though, and I thought the point of them was to make it flexible around the user. So I feel like I'm doing something wrong seeing as I've hit a small wall. #include <iostream> #include <cstdio> #include <iomanip> template <typename T> class stats { private: int n; T sum; public: stats() { this->n = 0; this->sum = T(); } void push(T a); void print(); }; int main() { std::string tmp; // change type based on

Sort vector of class objects based on some member variable

≯℡__Kan透↙ 提交于 2021-02-04 19:57:16
问题 Let class Record { public: Record(); private: string id; double score; }; Somewhere we define a vector of Record objects, i.e., vector<Record> records(N); // Initialize records somehow I would like to sort records based on score (in descending order) keeping track of the other member variables of Record (in this case just the score , but in general whatever else). 回答1: You can implement the comparison operators. bool Record::operator<(const Record& rhs) { return score < rhs.score; } bool

C# limit length of a string

瘦欲@ 提交于 2021-02-04 19:41:08
问题 I have the following class: public class VendorClass { public int VendorID { get; set; } public string VendorName { get; set; } } The fields above match fields in the database table. In the case of say VendorName , how do I give it a field width ? VendorName maps to a field in the database which is varchar(15) 回答1: You can't limit the length of the string but you can use properties with backing fields to achieve the desired result : public class VendorClass { public int VendorID { get; set; }

Class declaration confusion - name between closing brace and semi-colon

Deadly 提交于 2021-02-04 17:59:07
问题 class CRectangle { int x, y; public: void set_values (int,int); int area (void); } rect; In this example, what does 'rect' after the closing brace and between the semi-colon mean in this class definition? I'm having trouble finding a clear explanation. Also: Whatever it is, can you do it for structs too? 回答1: rect is the name of a variable (an object in this case). It is exactly as if it had said: int rect; except instead of int there is a definition of a new type, called a CRectangle .

How to search a text file for a specific word in Python

落花浮王杯 提交于 2021-02-04 16:46:35
问题 I want to find words in a text file that match words stored in an existing list called items, the list is created in a previous function and I want to be able to use the list in the next function as well but I'm unsure how to do that, I tried using classes for that but i couldn't get it right. And I can't figure out what the problem is with the rest of the code. I tried running it without the class and list and replaced the list 'items[]' in line 8 with a word in the text file being opened

What the difference between classes with space and no space in css, what the use of multiple classes with no space

China☆狼群 提交于 2021-02-04 16:29:34
问题 I am making an accordion using CSS, the below is my use of CSS class without space. I use this to eliminate the animation of padding during slideDown and slideUp effect .acc_container.block{ padding: 20px; } since it stated out that padding is 20 pixels but when i check it seems like no padding at all!! instead, i need to add this in order to let my padding works .acc_container. block{ padding: 20px; } (with space) So what's the difference between the class in CSS with and without a space?