Skip to content

Commit

Permalink
some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalrao009 committed Jan 9, 2025
1 parent a7e11b4 commit 1ef9583
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions wiki/vimwiki_html/Tools/Structures with templates.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,15 @@
T data1;
T data2;

MyStruct(T val1, T val2) : data1(val1), data2(val2) {} // it is simple way of initialising data1=val1 and data2=val2, in this case {} will be empty as its role has been done by initialising list.
MyStruct(T val1, T val2) : data1(val1), data2(val2) {} // it is simple way of initialising data1=val1 and data2=val2, in this case {} will be empty as its role has been done by initialising list. Here val1 and val2 are arguments passed by user.

void display() {
std::cout << "Data 1: " << data1 << ", Data 2: " << data2 << std::endl;
}
};

int main() {
MyStruct<int> intStruct(42, 77);
MyStruct<int> intStruct(42, 77);
intStruct.display();

MyStruct<double> doubleStruct(3.14, 2.718);
Expand All @@ -130,6 +130,23 @@

</pre>

<p>
A quick run of the above code block in visual mode in neovim runs by <br />
:!g++ -std=c++20 /tmp/vim_cpp_exec.cpp -o /tmp/vim_cpp_exec &amp;&amp; /tmp/vim_cpp_exec <br />
</p>

<p>
which one can set the keymapping in vimrc file by <br />
<code>vnoremap &lt;leader&gt;pp :w! /tmp/vim_cpp_exec.cpp&lt;CR&gt;:!g++ -std=c++20 /tmp/vim_cpp_exec.cpp -o /tmp/vim_cpp_exec &amp;&amp; /tmp/vim_cpp_exec&lt;CR&gt;</code><br />
</p>

<p>
Just selecting the code and pressing ',pp' (here &lt;leader&gt; is mapped to ',')<br />
Which gives the following ouput:<br />
Data 1: 42, Data 2: 77<br />
Data 1: 3.14, Data 2: 2.718<br />
</p>

</div>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/highlight.min.js"></script>
<script type="text/javascript">
Expand Down

0 comments on commit 1ef9583

Please sign in to comment.